#Jumping on moving platforms

10 messages · Page 1 of 1 (latest)

gray island
#

Hello, I'm trying to program a moving platform correctly. I noticed that with my movement script, my character, while it could go on the platform and move within the platform, when it jumped, it did not follow the velocity of the platform and would fall out of it. This is problematic not only in what I wanna do with the game design but also because it doesn't simply follow the rules of physics in general(an object in movement stays in movement). With that being said, I do believe this could be cause by how the Godot physics library works. My code is below, this define the movement for my playable character(Characterbody3d):

https://pastebin.com/1sUCdjt6

gusty trout
#

Check your CharacterBody setting for “velocity on leave platform”

Another factor is if your character can stop moving horizontally in the air, then the platform’s velocity won’t carry over for the entire jump. Most games don’t let you just fully stop in the air, only change direction.

Try swapping the else on line 31 with this:
elif is_on_floor():

This will check you’re on the floor before letting your velocity stop. Now whenever you jump, it will keep momentum, you can change direction but not stop.

gray island
#

what do you mean by CharacterBody setting?

#

ok i see what you're talking about and this is what I have

#

and I also changed the code, the results were still the same. I can't seem to jump on the platform normally

gusty trout
#

What do you mean by “jump on the platform normally”

#

Is your moving platform an AnimatableBody?

gray island
#

yes