0 votes

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

  1. If I call setlinearvelocity() after I call setrot(), my velocity no longer apply. If I comment out the setrot() setlinearvelocity 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?

asked Nov 8, 2017 in Engine by IAmAGorillaKing (12 points)

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: http://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html?highlight=rigidbody2d#class-rigidbody2d-apply-impulse

Or set the linear velocity directly like you tried.

I don't know about 1) though.

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

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.