How do I attach a variable to animation?

0 favourites
  • 8 posts
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • I have four different animations for a sprite. I had an idea to attach a variable number for each animation of an object to affect where they spawn in. Perhaps I'm looking at it the wrong way? Perhaps there's something else I can do instead?

  • I'm not sure if I understood your question, but if you are looking for a way to spawn the same sprite with different pre-defined animations and values, you can use templates.

    Put all these sprites on an unused layout, configure their instance variables and set animations. Give a template name to each instance. You can then specify template name in "Create object" and "Spawn object" action to create an object from a particular template.

  • I think you understood correctly. However, I myself am having trouble with understanding some of the context here. How can I implement templates in animations? Do I name the template the same as the animation?

  • Say, you have a single Enemy sprite with animations Zombie, Skeleton and Goblin.

    Put 3 copies of this sprite on Assets layout. Configure the animation and instance variables like HP, armor etc. And give a name to each template:

    When you create an Enemy from "goblin" template, it will be created with the correct animation and variable values.

    Templates are not related in any way to animations. You can have multiple templates with the same animation, for example "zombie_soldier", "zombie_medic"

  • Say, you have a single Enemy sprite with animations Zombie, Skeleton and Goblin.

    Put 3 copies of this sprite on Assets layout. Configure the animation and instance variables like HP, armor etc. And give a name to each template:

    When you create an Enemy from "goblin" template, it will be created with the correct animation and variable values.

    Templates are not related in any way to animations. You can have multiple templates with the same animation, for example "zombie_soldier", "zombie_medic"

    I think I have it now.

    Thanks for the example, it really cleared things up. Now how do I trigger a spawning to a certain event OR a timeframe, say, of 5 sec of that event not happening?

  • You can use Timer behavior. Or increase a variable every 1 second, and check if it's >=5 seconds.

  • You can use Timer behavior. Or increase a variable every 1 second, and check if it's >=5 seconds.

    For this... I might also need another example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Start a timer. In "On timer" event spawn a new object.

    There are plenty of tutorials and detailed documentation:

    construct.net/en/make-games/manuals/construct-3/behavior-reference/timer

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