Pick instance by comparison via UID

0 favourites
  • 9 posts
From the Asset Store
Screen Comparison
$2.40 USD
40% off
See how your Logical Resolution looks on different devices
  • 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.

    copy.com/JdsiG1uaT4e1

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • I assume your problem is solved - correct?

    Cheers,

    thegrind

  • 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.

  • 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?

  • I'd like to destroy the feet and disable the bullet behavior for only the enemy instance the player collides with.

  • 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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)