This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm developing a game for learning with free assets, the game is a 2D platform, the character movement tutorial in the godot documentation and internet tutorials serve well to move and jump the character horizontally and vertically, but I want when the character is going up diagonally use the "movement" sprite but because of the code that activates gravity the character is going down alone and activating the descent sprite when I go up it activates the jump sprite.

enter image description here

the image above shows the character descending and with the falling sprite activated I just want him to walk on the platform.

**I'm following godot's movement tutorial https://docs.godotengine.org/en/stable/tutorials/physics/kinematic_character_2d.html**

in Engine by (12 points)

1 Answer

0 votes

Hard to say without seeing your animation code, but generally you would only set a jumping or falling animation when is_on_floor() is false. The logic would be something like:

if !is_on_floor():
   if velocity.y > 0:
      animation.play("falling")
   else:
      animation.play("jumping")

The character sliding down the slope on his own is a little more advanced since you would have to make use of the moveandslidewithsnap() function. This keeps the character "snapped" to the floor even when gravity is being applied. Just note that you would also have to "unsnap" the player when jumping. For a tutorial, check out this Pigdev video.

by (104 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.