How can I make it so that the player can only jump when he is on top of the platform????
VinnyAmatoGames
Member Posts: 18
Hi. I am making a game where the platforms are moving from left to right across the screen while the player jumps on them. The player can only jump when touching a platform. When the player falls the scene is reset. My issue is that when the player is falling if he touches the side of the platform it still gives him the ability to jump. I do not want this. How can I fix this???? - Vinny
Comments
Its Really Simple ,
create an attribute jumpOnly which is a boolean.
When jumpOnly is 1 and Hero collide/touches platform make him jump...you change from any to all.. that it...Any way I'm new to GameSalad Hope it works...
My Games Link:
https://itunes.apple.com/au/app/real-ants/id932999551?mt=8
lhttps://itunes.apple.com/au/app/horse-challenge/id930967102?mt=8
Hi @VinnyAmatoGames
I'm not totally sure how does your game works but maybe you can control that with the position of the main character, the "Y" value in the position,
For example, if the "Y" value (self.position.Y) is lower than the "Y" value of the platforms (I think that case is when he's falling) then disable the option to jump, I don't how you control that but you I'm sure you can disable it whit that rule.
I think this is how the rule inside your main character looks like in case the value "Y" in the position of your platforms are maybe 100 just saying and you control the jump with one boolean attribute named "Jump" :
attribute: self.position.Y < 100
{
Change attribute
{
Jump "to" False
}
}
I Hope this is helpful for you and solve your problems how you want.
Good Luck with your games!
The tutorial below shows you one way to detect the top of an actor vs the bottom, I'm sure it could be adapted for the sides instead:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page