Why does my KinematicBody bounces between StaticBodys?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bastilo

Hi,

I have a KinematicBody (3D) that has simple gravity (every physics process tick: add the gravity value to the y coordinate via “move_and_slide”). It moves smoothly on one StaticBody but if it reaches the next StaticBody (which is - in this case - a copy of the same body directly next to the first StaticBody) it bounces a little bit up for a very small moment.
I think it’s a very simple task to move a KinematicBody over different collision shapes of the environment without bouncing or stuttering. What do I miss here?

Edit:
To try it for yourself just create a scene with two StaticBody boxes next to each other but on the same y level and a KinematicBody with this script:

extends KinematicBody

const GRAVITY = 1.0
const SPEED = 1.0

func _physics_process(delta):
	var linear_velocity = Vector3(0, -GRAVITY, 0)
	if Input.is_action_pressed("ui_up"): linear_velocity.z -= SPEED
	if Input.is_action_pressed("ui_down"): linear_velocity.z += SPEED
	move_and_slide(linear_velocity)
	print(global_transform.origin.y)

In my case, the KinematicBody is on y position 0.80902 when it’s colliding with one collision box and on 0.817xxx (the last 3 digits differ each physics frame) when it’s colliding with both boxes at the same time.

I have expirienced same problem. It is very bad if you are colliding with 4 static bodies, for exsample standing on the edge of 4 cubes like you would in voxel(minecraft) like game.

Golimonkey | 2020-03-10 13:47

:bust_in_silhouette: Reply From: arthurZ

Maybe using move_and_slide_with_snap with the snap == true could solve it.

Sadly, this is not working either. If I apply the linear velocity vector as the snap vector it just behaves as before (bouncing) and if I apply Vector3(0, -1, 0) as the snap vector the player just stops before the new StaticBody (like it behaves if I just use move_and_collide).

bastilo | 2020-03-09 13:46

Did you try the max angle argument equals 46 or above degrees (even 60º) in the move_and_slide_with_snap? Please, try this.

arthurZ | 2020-03-09 14:43

Yes, this has the same effect as before.

bastilo | 2020-03-09 15:14

:bust_in_silhouette: Reply From: bastilo

I just found out that this is an engine bug that is hopefully fixed in the next release.