Got multiple instances of AI with Spriter animations working

0 favourites
  • 4 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Had to get this off my chest as it was a mind f$$k.

    I made a bad guy with blind spots that patrols the level with collision detection while also using spriter animations. If it spots the player it aims its gun in the players direction and fires bullets at the player. This was pretty straight forward apart from a quirk with spawning bullets from the end of the gun in a spriter animation!

    So I placed two bad guys in the level and suddenly I had to have a way of the game knowing which objects belonged to which AI. For instance I had the following problems.

    -An AI detected an obstacle so it is told to turn around. However all AI would turn around.

    -An AI detects the player and aims at it yet all AI aim the gun at the player but only one AI is spawning the bullets (Not the correct one either).

    -Finding out the gun position within a spriter animation when the spriter plugin has constructed each animation instance.

    Its done now and it's all pretty cool. I think I need a beer!

  • How did you solve this? I'm having a problem picking instances of spriter objects when using multiples of the same object. Please help!

  • jaredhd

    So what you do is make sure you duplicate all the objects associated with one instance. i.e. Spriter object (SpriterObject), the Sprite object you attach the spriter object to (TextureObject), etc. Then for each of theses objects you set a variable called SpriterNo and set it to the same number for each group of objects. So each instance is made of objects who each have have the same variable with the same number unique to that instance.

    Then you use the following actions to make sure each instance is given it's own command.

    Foreach [SpriterObject]

    Pick [TextureObject] that [TextureObject.SpriterNo] = [SpriterObject.SpriterNo]

    ...Add sub actions here...

    So this loops through each Spriter object and grabs the Sprite object associated with it.

    However, If you want to command a specific instance then you can instead do the following.

    Pick [SpriterObject] that [SpriterObject.SpriterNo] = 1

    Pick [TextureObject] that [TextureObject.SpriterNo] = 1

    ...Add sub actions here...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For even more fun, make your object a container and throw in a dictionary or array...

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