Hello. I’m pretty new to Godot nearly 1 month of first of using the engine and i have ran in to a problem .
until now i have only made simple games following tutorials making games where you can move in all four directions and so i thought its finally time to make a platformer .
So i started following a tutorial by heartbeast
and thing were going pretty smoothly until i tried adding gravity and things just stopped working
i added gravity like in the tutorial and my charecter woundnt move left or right i have to press the up button more than once for the charecter to jump.
Here is the code please someone help i hhave spent hours trying to fix it and im loosing my mind :
Btw i used move_and_collide() here cause move_and_slide() dosent take in arguments anymore and i know velocity is now built in and i tried using move_and_slide() but the movement was very wired so i switched over to move and collide()
Also Can anyone tell me how i can use is_on_floor with move_and_collide()?
Well the point of move_and_slide() is that the character can slide/move even when it’s colliding. So you can collide with the floor and still move left and right.
But with move_and_collide() the character stops when it’s colliding with anything, so it’s normal that it can’t move when gravity makes it collide with the floor.
move_and_collide() is meant for objects that should move until they collide with something, like bullets for example. I don’t know if there’s a good way to make it work for character movement.
Imo you should try using move_and_slide() and figure that out if it has an issue.
yeah I tried move_and_slide() but it doesn’t take in arguments anymore and the movement was very wired
But thanks for the exclamation ill try to figure out what i can do to fix that.
I don’t know how to do that .
But I made move_and_slide() is working for me now .
i just 15 minutes tweaking somethings and now it works perfectly .
But thank you for the suggestion .