Author Topic: How to create my own hero state ?  (Read 2644 times)

Konbuscus

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to create my own hero state ?
« on: August 13, 2016, 10:26:18 am »
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 :)

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
Re: How to create my own hero state ?
« Reply #1 on: August 13, 2016, 11:56:24 am »
You can use the "frozen" state and then set the animation and movement you want.

Konbuscus

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to create my own hero state ?
« Reply #2 on: August 13, 2016, 01:04:50 pm »
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
« Last Edit: August 13, 2016, 02:23:02 pm by Konbuscus »

Diarandor

  • Hero Member
  • *****
  • Posts: 1047
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: How to create my own hero state ?
« Reply #3 on: August 13, 2016, 09:14:52 pm »
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.”

Konbuscus

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to create my own hero state ?
« Reply #4 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.

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: How to create my own hero state ?
« Reply #5 on: August 15, 2016, 04:13:47 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

Diarandor

  • Hero Member
  • *****
  • Posts: 1047
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: How to create my own hero state ?
« Reply #6 on: August 15, 2016, 09:48:58 pm »
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).
« Last Edit: August 15, 2016, 09:50:38 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Konbuscus

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to create my own hero state ?
« Reply #7 on: August 16, 2016, 10:45:57 pm »
Thanks to all your advices, I finnaly manage to making him keep his Transformation !

The Tunic trick works perfectly !