Possible bugs in 2D physics engine

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

I am using 2.1.4 and I am having a 2 issues with the 2D Physics engine:

  1. If I call set_linear_velocity() after I call set_rot(), my velocity no longer apply. If I comment out the set_rot() set_linear_velocity as expected.

  2. add_force seems to apply the force continuously even when i only called it once.
    Here is my example:

var apply_force = true
...
func _process(delta):
  if(apply_force):
    add_force(Vector2(-17, 0), Vector2(10, 0))
    apply_force = false

Even though I only apply the force once, my RigidBody2D still speed up each frame.
Is this intended or is there a way to turn it off?

I think add_force does it job correctly, it adds a force which cumulates to all forces already applied. Your object speeds up because there is no force to slow it down (friction or gravity for example).

You can add also apply impulses: RigidBody2D — Godot Engine (stable) documentation in English

Or set the linear velocity directly like you tried.

I don’t know about 1) though.

Zylann | 2017-11-08 13:54

And don’t do that in process, do it in fixed process where physics logic should take place.

eons | 2017-11-10 10:53