Hello all,
I am having problems resetting the rotation of my RigidBody2D. I have already googled for solutions but nothing previously posted in topics seems to work, so I'll elaborate on where I am:
- I'm making a top-down football game with the ball as a RigidBody, and after goals/free-kicks etc. I want to reset the rotation (degrees) to 0.
- I am aware that RigidBody2Ds need to use the
_integrate_forces
method to directly alter their states. This is what I used to reset the ball's position:
state.transform.origin = reset_position
- However I can't find an equivalent command to change the rotation without applying a force to the ball.
- In the process of debugging I have found that the rotation is changed for a frame, then promptly reset back to the old value by the engine.
- If I drop a
set_rotation(0)
, or a rotation = 0
, or a rotation_degrees = 0
into the main body of _integrate_forces
, it will override the engine and prevent any rotation of the body. This demonstrates that they work on some level but it's not the effect I'm going for, as I only want to reset the ball's rotation in certain circumstances and let applied forces take care of the rest.
So, is there a way to directly assert the rotation of a RigidBody? Is the only solution to change the type of the ball to something else, because apart from this issue it has worked very well?
Many thanks.