How do I assign health to spawned objects?

0 favourites
  • 8 posts
From the Asset Store
Custom animated Health Bar - check youtube video to make it yourself
  • Hi,

    I referred to this spawner example and am able to use this to use the wave method shown in the capx. .

    My second purpose is to store health in each spawned object and upon collision with another object, subtract by 1 and destroy when 0.

    As per the example, I included an additional variable - health and maintained the health in the array e.g spawner/amount/type/health - "1;2;Yellow;1|1;1;Green;2|0;3;Red;1;3"

    I created an instance variable on my enemy sprite - HealthX.

    Under the as Spawn function, I set the health-local variable to the spawnobject and added another line to set healthx to health.

    Separately, I have an event that upon collision, subtract 1 from healthX of the enemy sprite and one more event for e.g if pick instance with enemy.uid & healthX less than zero ->destroy the enemy sprite.

    It doesnt seem to be right somehow. Can someone advise if there is a better method for this purely to detect collision of individual sprites for subtraction or if there is another topic which I can refer to?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • what happens to the objects on collision? is first one delated or do they stay next to each other?

    try to add everytick to collision detection.

  • collision detection is already check every tick

  • I have checked that the collision detection is enabled. Any other suggestions to look at?

  • I'm curious to see the events that you used to have this problem... If you can post screenshot or capx....

  • I basically edited the example that I mentioned earlier.. Do have a look here.. . com/s/6muo88q825bke5n/spawn_with_health.capx?dl=0 . I am trying to assign a health value e.g 1,2,3 to each sprite spawned.

  • Nothing seems happen in your example

  • Like I said, I am trying to add health to the exising spawner example that I mentioned in the first post.In the original capx you will find that it will spawn objects with diff colors.

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