Pick instance by comparison via UID

Get help using Construct 2

Post » Sat Oct 26, 2013 2:50 pm

In my top down shooter I have different enemies made up of several sprites each which are pinned to the main enemy sprite. When an enemy collides with the player or player projectiles I want some of the sprites of the enemy to disappear, some to stop moving and others to change frames/animation based on the nature of the collision or overlap.

At this stage I don't want to use families and containers don't seem to be suitable. I'm trying to pick each of the sprites for a given enemy using "pick instance by comparison" and instance variables, but I'm unable to achieve the desired result, probably because my system pick events are not correct.

The .capx linked below contains a simplified example. Any suggestions appreciated.

https://copy.com/JdsiG1uaT4e1
B
5
S
1
Posts: 44
Reputation: 665

Post » Sat Oct 26, 2013 8:31 pm

In your Player collision with Enemy, you don't select EnemyFeet - thats the problem.

Another thing - be careful with collisions, sometimes (depends on incoming angle) you might not detect collisions, because the Enemy hits the PlayerFeet sprite, but you check if Enemy collides with the Player sprite.
B
26
S
9
G
2
Posts: 78
Reputation: 2,524

Post » Sat Oct 26, 2013 9:05 pm

One thing I forgot to put in the capx is that apart from the "Enemy" sprite the other sprites pinned to the enemy and player (such as feet) will have collisions disabled, so this is why I haven't selected enemy feet in the collision event.
B
5
S
1
Posts: 44
Reputation: 665

Post » Sat Oct 26, 2013 9:36 pm

I assume your problem is solved - correct?

Cheers,
thegrind
B
26
S
9
G
2
Posts: 78
Reputation: 2,524

Post » Sat Oct 26, 2013 10:17 pm

No, I don't think the feet were the issue. The problem I'm having is that when the player and enemy sprites collide the feet (and other sprites) pinned to all other enemy instances are also destroyed. But the bullet behavior is correctly disabled for only the enemy instance that collides with the player.
B
5
S
1
Posts: 44
Reputation: 665

Post » Sat Oct 26, 2013 10:30 pm

Do you want to disable the bullet behaviour, for all Enemy instances when any given Enemy instance collides with the player, or do you want to disable the bullet behaviour, only for the Enemy instance colliding with the player?
B
26
S
9
G
2
Posts: 78
Reputation: 2,524

Post » Sat Oct 26, 2013 10:49 pm

I'd like to destroy the feet and disable the bullet behavior for only the enemy instance the player collides with.
B
5
S
1
Posts: 44
Reputation: 665

Post » Sun Oct 27, 2013 1:29 am

Hi

I still think you didn't pick right, and I delivered the solution to that, in my first reply. However I got intrigued by the collisions taking place, relating to the pick of EnemyFeet by comparing distance. Seems unreliable - measured weird distances, which in effect didn't trigger the function call, despite collision being detected - I dunno why :(

You might find the capx file, resulting from my tests, useful:

uidpick_collision_test.capx

Cheers,
thegrind
B
26
S
9
G
2
Posts: 78
Reputation: 2,524

Post » Sun Oct 27, 2013 12:08 pm

Capx file was very helpful. I see what I was doing wrong now. Using imagepoints for measuring distances also seems to work better.

Thanks a lot.
B
5
S
1
Posts: 44
Reputation: 665


Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, kiki4construct and 31 guests