Destroy instance without picking it

Get help using Construct 2

Post » Thu Mar 22, 2012 8:59 am

Hi there, i need a little help.

Following Situation:

1 Bullet
20 Targets (Instances)

Event: On Collision Bullet -> Target
Action: Pick Target beside the one which was collided (neighbor)and destroy this one.

I think it is not possible to pick another Instance during this collisions event.
Is it possible to destroy a instance without picking it ?
What is wrong in my way of thinking ?

Thank's
B
8
S
1
G
2
Posts: 13
Reputation: 1,901

Post » Thu Mar 22, 2012 5:01 pm

Yeah, I once did something similar. It went something like this.

I had an instance variable on the "target" called objectID that was an internal ID I was keeping, so there would be no two targets with the same ID (probably I could have used the UID but anyway).

Event: Bullet on collision with Target, Actions save Target.objectID to a local variable auxID, Target.X to auxX, Target.Y to auxY
SubEvent
- system pick all Targets
- Target.objectID <> aux
- Target.X > auxX - 100
- Target.X < auxX + 100
- Target.Y > auxY - 100
- Target.Y < auxY + 100
      Action for subevent            -> Target.destroy

This should destroy all targets within 100 "radius" (rather a rectangle but too lazy to do sin, cos etc) of the hit, except the one which got hit.
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Thu Mar 22, 2012 11:35 pm


Hi, OK

I've learned:

Pick All of a object which is involved in the collision, then reduce the picked ones with the help of local variables (NOR).
Instead of adressing the uid directly.

(The "Destroy-Range" effect is a cool and easy idea !)

I keep on testing a little bit with this solution, thank you

But anyway, i need first a pick and then destroy.
Picking a third object under an collision event i.e. in a subevent isn't possible (?)
B
8
S
1
G
2
Posts: 13
Reputation: 1,901

Post » Fri Mar 23, 2012 10:26 am

Yes you need to pick what you want to destroy, if you don't pick, it will destroy that which is already picked, i.e. the target that was involved in the collision. You got this right now.

Not sure what you mean by picking a third object under a collision event, in a subevent. If you mean an object of a type that wasn't involved in a collision (e.g. "bullet" and "target" collided, and you want to pick "flower"), that IS possible, just tell the System->Pick all what to pick, or filter by that directly, i.e.

event: bullet on collision with target
event action: save coordinates to some local variables like in my post above

subevent: flower->[...compare X and Y like in my post above...]
     subevent action->flower.destroy

This should destroy all flowers around the collision, and not destroy the target or the bullet.
B
14
S
5
G
7
Posts: 235
Reputation: 5,175


Return to How do I....?

Who is online

Users browsing this forum: Aserak2012, Colorfish, Waltuo, Yahoo [Bot] and 4 guests