How to create my own hero state ?

Started by Konbuscus, August 13, 2016, 10:26:18 AM

Previous topic - Next topic
Hello everyone, I'm facing an issue right now.

In deed, I want my hero to play an animation when I'm pressing a key, (that's done), and then I want him to get another state, a customized state, is that currently possible ?

Thanks :)

You can use the "frozen" state and then set the animation and movement you want.

August 13, 2016, 01:04:50 PM #2 Last Edit: August 13, 2016, 02:23:02 PM by Konbuscus
OK. I'll give it a try. But I want my hero  to get  another default animation after the animation, is that possible too?

Maybe this gif can help you to understand :

https://gyazo.com/b1fb6cc6ce17a29c4c0500d49ddd3cee

Yes, it is possible to change the default stopped and walking animations (and all the other animations). I know two possible ways to do this:
1-Change the tunic sprite of the hero. This is the easy way and you should do it this way.
2-Use a script to fix the new animations. This way is much more complicated and probably not the good one for your purposes, although it has the advantage of keeping the same sprite (which can be useful for other purposes to avoid using too many sprites).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Hello, so I just created all the animations I needed for the "power up".

But when he turns into a super saiyan, I launch the stopped animation then, the walking one, but instead of just stopped and walking, it takes the default  stopped and walking animation.

I've no idea of making him keep that transformation.

Quote from: Konbuscus on August 15, 2016, 02:51:02 PM
Hello, so I just created all the animations I needed for the "power up".

But when he turns into a super saiyan, I launch the stopped animation then, the walking one, but instead of just stopped and walking, it takes the default  stopped and walking animation.

I've no idea of making him keep that transformation.

Use another tunic sprite. (In sprites/hero/)
Copy / paste the default tunic sprite, and rename it tunic.saiyan or whatever you want, open the .dat in notepad++ or whatever script editor program.
Replace the stopped/walking animation by the super saiyan one


In your script then

hero:set_animation("transforming_into_saiyan", function()
  hero:set_tunic_sprite_id("hero/"your_super_saiyan_tunic)
  hero:unfreeze()
end)

If you want to revert, then do the same trick

August 15, 2016, 09:48:58 PM #6 Last Edit: August 15, 2016, 09:50:38 PM by Diarandor
The reason why it is necessary to use another tunic sprite is that in order to start an animation of the hero you need to freeze him with hero:freeze(), and while the hero is frozen you cannot walk or control him, which would not allow to you to move him with the new animation. So in your case, change the tunic sprite and you have finished.

In a different situation when you make a cutscene where you do not control the hero and you need to start some animation on him, then freezing the hero and starting the animation would be the best solution since a new sprite would not be needed in this case.

Note that when the hero is not frozen, the engine automatically upadates the stopped and walking animations to the default ones, so you cannot use a custom walking animation this way (well, there is a way to do it but you do not need it, and it is more complicated because requires using scripts).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Thanks to all your advices, I finnaly manage to making him keep his Transformation !

The Tunic trick works perfectly !