How to make a button make an actor jump?
PurulentSoftware
Member Posts: 15
Hello
Does anyone know how to make a button control a character. I already have the stuff set up to make my actor jump... The only problem is i cant figure out how to make the button send the message to the actor to jump? I know i can probably use a bool but is there an easier way?
Does anyone know how to make a button control a character. I already have the stuff set up to make my actor jump... The only problem is i cant figure out how to make the button send the message to the actor to jump? I know i can probably use a bool but is there an easier way?
Comments
Thanks
So the actor (the button) sensing the press would set a game boolean attribute to "true" (i.e. call it "PlayerJumping"). Then the player actor could have a rule that if "PlayerJumping" is true, do the jump code/routine and then set "PlayerJumping" to false to signal jump complete.
This would need to be played with if you add a super-jump or something (i.e. press jump again at the top of the jump for extra height).
Your button actor sets game.up_pressed to 1 when pressed, otherwise it sets game.up_pressed to 0. Your player has a rule that jumps when game.up_pressed is true.
The nice thing about doing it this way is then you can have multiple ways of sending the up_pressed signal to the player. You can make it so when you press the up key on the keyboard it sets game.up_pressed to 1, or when the user touches an onscreen button. This way the same game can work for iPhone and for web without having to edit the actors around much.