Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nostalgic_gamer |
Hi there,
I’m making a game with RigidBody2D as my main character.
The reason I’m using a RigidBody2D and not a KinematicBody2D is that I don’t want to re-code the physics, especially when character is in the air and could be subject to multiple outside factors (breaking, wind, boost etc).
I’m trying to make a game with some very similar mechanics than:
- Alto: http://altosodyssey.com/
- Trials Rising Trials® Rising on Steam
The problem I have is that when applying a force to my body, it randomly jumps as if it were colliding with the ground.
The issue is that this happens even on a perfectly flat surface like when drawing a Collision2D with a programmatically generated rectangle.
I’ve tried messing with the gravity, friction, safe margins with one way directions etc, but didn’t manage to avoid those weird bumps. (BTW I’m not really sure I properly explore the one way direction, as I didn’t really manage to see any changes when moving the safe margins).
I’ve also looked at all the similar issues I found via Google:
- https://forum.godotengine.org/39301/can-ignore-the-collisions-located-between-two-tiles-tilemap
- https://forum.godotengine.org/39301/can-ignore-the-collisions-located-between-two-tiles-tilemap
- https://forum.godotengine.org/29122/make-a-rigidbody2d-player-move-smoothly-with-the-floor
(and a lot others more or less closely related to the same issue).
All the answers I saw revolved around either using a KinematicBody2D or switching somehow dynamically to a Kinematic mode on the RigidBody2D.
-
I understand using a KinematicBody2D for everything gravity related would mean I need to recode everything gravity wise. How complex would that be for a game such as the ones mentioned above?
-
To your knowledge, is using a KinematicBody2D the only way to avoid weird bumps like the ones I described?
-
I understand that the issue is related to some kind of physics approximation, would there be a way for me to to use
_integrated_forces
to skip some collisions or adjust the applied force direction I have a way to detect the angle was badly approximated? -
When switching the RigidBody2D to a Kinematic mode, you need to recode the move_and_slide your self. Is there a better way?
What I’m trying to achieve in the end is something like “move_and_slide_with_snap” for a RigidBody2D, and avoiding those weird bumps.
Thanks a ton for your help,
I’ve also looked at some Unity videos where this problem doesn’t seem to occur, I was really hoping to solve the problem in Godot 3.2.