How do I differ one object from others

Get help using Construct 2

Post » Sat Nov 01, 2014 12:59 am

I have two same object appears at the same time, but created in different inteval. When my hero shoot at one object, the other one responded too. How to prevent other object from same group to respond?
I'm using free version. Thanks.
We're just a sprite in digital earth
B
9
S
3
Posts: 43
Reputation: 970

Post » Sat Nov 01, 2014 1:06 am

What do you mean by "responded"?

Events like SpriteA on collision with SpriteB -> destroy SpriteB will only destroy a SpriteB instance that was picked by collision, other instances will not be affected.
If you post your capx file, or screenshot of your events, then we could find out what is going on.
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,597
Reputation: 34,821

Post » Sat Nov 01, 2014 1:20 am

Here is the screenshot of my events.

Hero will shoot harpoon, and when hit the enemy, a rope will appears connecting hero to the enemy, and that enemy will pulled closer to hero and destroyed.

PROBLEM:
The other enemy on screen will pulled also without rope.
You do not have the required permissions to view the files attached to this post.
We're just a sprite in digital earth
B
9
S
3
Posts: 43
Reputation: 970

Post » Sat Nov 01, 2014 1:30 am

That is correct
because in event System: ShootEnemy = 1 you are not specifying which instance of the enemy should be affected.
You are saying "if ShootEnemy = 1 then set angle of all Enemies towards player"

Give your enemy a variable - boolean "hit" will be fine. and then:

-Harpoon: On collision with Enemy -> Enemy.hit set to true

-System: ShootEnemy = 1 and Enemy.hit = true -> Set enemy angle etc....
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,597
Reputation: 34,821

Post » Sat Nov 01, 2014 6:07 am

Thanks, Shinkan!
I miss the instance variables stuff. Now it works! :))
We're just a sprite in digital earth
B
9
S
3
Posts: 43
Reputation: 970


Return to How do I....?

Who is online

Users browsing this forum: Nicolas951, rayolf and 22 guests