Open hoelzl opened 7 years ago
We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth.
I found a way to workaround this problem:
After setting the position/rotation you want, keep the corresponding transform.
position = launch_position
ball_transform = get_transform()
Then in the _integrate_forces(state) function apply the transform to the state.
state.set_transform(ball_transform)
Setting position on a CollisionObject should set the state transform too, then? (I wonder if that could solve some issues on other objects, like moving areas)
This will not work because position is not sent immediately to physics when you change to staticbody, but the use case is really weird, I wonder if its worth working around it somehow to make it work
I can think of many use cases for teleporting bodies in any mode, state access should be easier (and safe).
Still valid in 3.2.3
Operating system or device, Godot version, GPU Model and driver (if graphics related):
Windows 10, current master branch (6d233c651b21ecaef78fbb20d0365a22919b72b1), nVidia GeForce GTX 1080, driver version V385.41 (but probably not related to GPU)
Issue description:
When switching a RigidBody2D to
MODE_STATIC
orMODE_KINEMATIC
, changing its position, and then switching back toMODE_RIGID
and applying an impulse, movement starts at the position where the previous movement stopped, not at the current position.Steps to reproduce:
In the example project, move the ball to the green area and click LMB to launch the ball. Move to the red area and click the button again to attach the ball to the mouse. When moving the mouse the ball sticks to the mouse position as expected. Click the mouse button over the red area; the ball will launch in the green area, not from its current position.
Link to minimal example project:
2D-Physics.zip