Make instances within families react differently?

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • How do I get it so I can have 1 family for 5 different enemies, but have each individual act differently. Or say, pick family instance EXCEPT Enemy 1.

    Example:

    I want enemies to react differently to being hit.

    -Some enemies I want them to do death animation on hit.

    -Some enemies I want to do a hit animation, and reset their attack counter

    -Some enemies I want to not even flinch on the hit.

    -I want ALL enemies to get -50 HP, EXCEPT Enemy 1

    I hope I explained it well. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You have a family called ENEMY. There is a wolf, a vampire and an alien that are all enemies. Give the family an instance variable called "Name". Then you can give each instance an appropriate name. So if an ENEMY is hit, you can pass along the NAME of that specific enemy which will determine what kind of enemy. You can call a function and pass the name of the ENEMY as an arguement for that function for the function will know what to do.

  • "You have a family called ENEMY. There is a wolf, a vampire and an alien that are all enemies. " Thought this was going to be the beginning of a bar joke   

    <img src="smileys/smiley36.gif" border="0" align="middle" />

    hmmmmm i think I see. I could say if EnemyFamily is hit AND EnemyType =/= 'Wolf': -hp and Set State "Hit".

    Then have a separate sub-event that says

    if EnemyFamily is hit AND EnemyType = 'Wolf': -hp and Set State "Angry".

    Ill try it out to see if it works

  • bscarl88

    Pretty much that is right. But instead of have the condition if EnemyFamily is hit AND EnemeyType <> "Wolf": -hp, you could just make another family instance variable called HitDamage. Then give each instance its own HitDamage which will determine how much damage they receive. Set the Wolf's to zero if you don't want him to receive any damage.

  • But that would mean that for every action, I would have to say If enemy is hit and enemyType = Alien, do this. or for every individual enemy type. I think if I want my enemies to react differently to every time of object, then I will have to do it individually

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