Kinematic2D jumping on collision

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Brandon
:warning: Old Version Published before Godot 3 was released.

I have a KinematicBody2D object with this simple script:

extends KinematicBody2D

func _ready():
	set_process(true)
	
func _process(delta):
	move(Vector2(.04, 0))

When the object collides with another object (whether it’s a static or rigid body), it teleports back some non-fixed distance. Here’s a gif–the moving object is the Kinematic, the object it’s hitting is a rigidbody, and the third object is a staticbody:

Gif of problem

None of the other objects (sprites, physics bodies, or collision shapes) have scripts attached to them. I’ve already restarted Godot, deleted every object and tried again, and changed all the collision shapes, but the same thing happens every time.

Any ideas at all why this could be happening and what I can do to fix it?

:bust_in_silhouette: Reply From: eons

The problem could be that you are using _process instead of _fixed_process

https://godot.readthedocs.io/en/stable/tutorials/2d/kinematic_character_2d.html#fixed-process

Thank you. I guess that’s what I get for using an outdated tutorial and not searching the documentation thoroughly.
Now I’m remembering fixedUpdate() from playing around with Unity. I never actually bothered to look up the difference. Now I know.

Brandon | 2017-01-03 22:46

AnimationPlayer, Tween and can’t remember if any other node, has a process mode that can be set to fixed too to work with physics.


With Unity was told to not use it, and got problems with input reading in OSX with a simple game…

eons | 2017-01-04 00:50

Interesting. Guess we were looking at different tutorials or something.

Brandon | 2017-01-05 23:35