0 votes

Physics stepping seems to happen two frames after applying velocity or force. Is this intended?

I would assume it would happen on the next frame. Not two frames late.

I have the following example. I apply a velocity at 10, but the body doesn't hasn't moved until frame 12. I would hope it would have moved already at frame 11.

 func _physics_process(delta):
        match frame:
                linear_velocity = Vector3(1,0,0)
                linear_velocity = Vector3(0,0,0)

        print("frame: " + str(frame) + " vel " + str(linear_velocity) +" " + str(transform.origin))

        frame += 1

And it gives me the following output

frame: 9 vel (0, 0, 0) (0, 0, 0)
frame: 10 vel (1, 0, 0) (0, 0, 0)
frame: 11 vel (1, 0, 0) (0, 0, 0)
frame: 12 vel (0, 0, 0) (0.1, 0, 0)
frame: 13 vel (0, 0, 0) (0.2, 0, 0)
frame: 14 vel (0, 0, 0) (0.2, 0, 0)

Note: The behaviour is the same even if I apply a force to the body.

in Engine by (130 points)

I wrote the equivalent script for Unity. In Unity the rigid body is moving the next frame after setting velocity. This makes me think that this is some sort of bug in Godot.

Probably a bug. Because 2D physics is updated on the next frame.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.