I believe I am seeing behavior where when a
RigidBody passes over an edge of a
get_contact_local_normal() Z axis jumps to a different value. I am wondering why this might be happening, and how I can prevent this or detect this (short of filtering out large changes in values).
I am seeing this behavior on a ramp with a constant slope, so my understanding is the collision normal should be the same the whole way down. However:
- The collision normal seems to change and stay at a completely different value sometimes
- Sometimes there is a slight "jitter" where the collision normal changes briefly to a new value and then back to the old value.
I am trying to make the player camera rotate to always be parallel to the ground the player is on. The player is a
RigidBody and the ground is a
StaticBody. So to figure out the angle of the ground the player is sitting on I call
get_contact_local_normal() when the RigidBody is colliding. I then use this normal's Z axis to rotate the camera.
By printing to the console I have confirmed that this camera jumping movement is caused by the collision normal changing rapidly.
As you can see, the areas on the ramp where the camera jumps seem to line up with the edges of the collision shape:
Source code (pinned to the moment in time where I asked this question) can be found here
The behavior is occurring in the Player scene, the collision normal is extracted in the
PlayerCollision.cs script, and the camera is rotated in the