As you can see, the apply_impulse() has an offset, so the body should rotate in response. However, when the scene is run, the body does move upward but without any rotation. The same apply_impulse() when run from the _input() function does result in rotation.
I noticed this because I had similar inconsistent rotation response when using apply_impulse() in other functions. Anyone run across this before?
How much is the angular damp? maybe is nullifying the impulse on fixed process.
eons | 2017-06-29 22:27
No angular damp. And the impulse applied by _input()doesn’t get damped at all. Even with damping, you’d think there’d be some rotation, but it’s exactly 0.
kidscancode | 2017-06-29 22:51
And the shape is not a circle? I have noticed something weird (like no change on initial rotation) with bouncing circles but didn’t tested much.
Problem may be that you put the apply_impulse in _ready()
I experienced oddities when working with 3D Physics and not letting it “settle down” at least some fractions of a second directly after scene start. (Usually I give it 0.1sec). Can be that this is similar in 2D.
You can use a one-time timer or a counter (add up deltas) in _fixed_process for delaying the initial impulse.
For example:
extends RigidBody2D
var initialWait = 0.1
func _ready():
set_process_input(true)
set_fixed_process(true)
func _fixed_process(delta):
if initialWait>0:
initialWait=initialWait-delta
return
set_fixed_process(false)
apply_impulse(Vector2(-10, 0), Vector2(0, -200))
func _input(event):
if event.is_action_pressed("ui_select"):
apply_impulse(Vector2(-10, 0), Vector2(0, -200))
I thought of this, but the _ready() example was just to demonstrate the problem. It also occurs when the impulse is applied in another function called during the game.