Bullet owner

0 favourites
  • 4 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hi

    When a bullet hits a player, I want to know which instance of the enemy shot it (so I can increase it�s experince, or something). How can I do that?

    Thanks

  • The simplest solution is to add an instance variable to the bullet object (e.g. "SourceID"). Whenever a bullet is create, set the instance variable to the UID of the object it was spawned from. Then, whenever the bullets hits something, you can use the "Pick by UID" condition to find its source based on the bullet's instance variable.

  • I'd suggest that you assign Bullet an instance variable of "Parent" or something. Then, in the Bullet creation event, the correct Enemy is already picked since it's the one spawning the Bullet, so simply assign the value of Bullet.Parent to enemy.UID.

    Later, when the Player is hit and killed and you want to increase Enemy.XP, pick the Enemy by its unique ID and add to its XP.

    EDIT: Hah, ninja'd by zatyka!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add an instance variable to the bullet called "parentUID"

    When the enemy shoot a bullet, set "parentUID" to the enemy's UID

    Then on the 'bullet collides with player' event, add "pick enemy by bullet.parentUID" and this will pick the one enemy that shot the bullet.

    Edit: got double ninja'ed :P

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