-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't use Rigigbody2D's apply_impulse and apply_torque_impulse when in _ready() function #29888
Comments
Doesn't |
If it's updated at end of frame, you can't get calculated result at once after you apply impulse. |
Deferring the calculation too would be inconvenient, I guess? I'll tag it as bug, but it might be possible that it can't be fixed and it's more a documentation issue. |
I just encountered this too. My Player instances a throwing knife on a keypress and flings it using I was clued into this by a 2 year old reddit post which links to a similarly old forum post. |
I did some testing and found the following:
|
Godot version:
d2f38db
OS/device including version:
Issue description:
Create a normal rigidbody2D in scene, attach a script to it, and try to call
apply_impulse
orapply_torque_impulse
in_ready()
,it has no effect.Reason: Rigidbody2d's updating inertia is delayed to next frame, so when you call a function need mass or inertia in
_ready()
, it has no effect.godot/servers/physics_2d/body_2d_sw.cpp
Lines 36 to 40 in d2f38db
RigidBody has the same problem, the difference is RigidBody's inertia is inited with identity instead of zero.
Steps to reproduce:
Minimal reproduction project:
bug2.zip
The text was updated successfully, but these errors were encountered: