0 votes

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?

in Engine by (24 points)

1 Answer

+1 vote
Best answer

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

by (7,946 points)
selected by

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.

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...

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.