|Topic was automatically imported from the old Question2Answer platform.
I’ve recently started using version 4.0.2, but I’ve already ran into an issue.
The player character for my game slows down a lot when they’re moving against a wall, and can no longer go up slopes.
I feel like it might have something to do with this part of the code:
move_vec = move_vec.normalized()
move_vec = move_vec.rotated(Vector3(0, 1, 0), rotation.y)
move_and_collide(move_vec * speed * _delta)
Are there any ways to fix this issue?
I don’t think this is enough information to assist unfortunately. Looking at this code snippet I don’t immediately see what would be causing your issues. Would you be able to provide the code for the entire script and possibly a video showing the issue happening?
PolyBytes | 2023-04-30 14:29
It sounds like your player character may be getting stuck on the walls, which could cause the slowdown and difficulty with going up slopes. One possible solution is to use the move_and_collide() function instead of move_and_slide().
move_and_collide() allows you to detect collisions and adjust the movement accordingly, which could help prevent the player from getting stuck on walls. You can try using it instead of move_and_slide() and see if it improves the movement of your character.
Additionally, you may want to experiment with the floor_max_angle and floor_min_angle properties of your KinematicBody to adjust how steep of a slope your player can climb. By default, floor_max_angle is set to 45 degrees, which may be too steep for your player to climb if they are moving slowly.
Finally, you may want to check the max_slope_angle property of your KinematicBody to make sure it is set to an appropriate value for your game. This property controls the maximum angle at which your player can walk up slopes, and it may need to be adjusted based on the needs of your game.
I’m not sure if it’s working…
I’ve looked more closely at the problem with going up slopes. It’s possible, but the player moves up the slope very slowly. And if you go back down then the player’s collisionshape somehow goes halfway through the ground, making going back up the slope impossible.
I think it might have something to do with the snap length value.
Entity2020 studios | 2023-05-05 14:52
I’ve allowed the player to move on slopes a little bit faster and more smoothly, but I’ll have to find a way to make the player move up slopes properly. I think I might already know how to do it, but it would require a variable that checks the angle of the floor that the player is standing on.
If the angle of the floor is rather high, then it will multiply the move speed of the player by 2 or 3.
Entity2020 studios | 2023-05-05 15:19