Screen wrapping a rigidbody2D

Godot Version

4.3

Question

I am using a Rigidbody2D to move a ship like in Asteroids, if I use the ship’s position to screen wrap then all collisions fail after wrapping occurs. I understand that a Rigidbody2D should only be moved using forces but I am not sure how I would implementing screen wrapping which technically break physics and teleport the ship.

I think I could not use a Rigidbody2D but I really dont want to implement the forces based movement myself.

Any help will be appreciated, thanks

I’m not sure exactly how to solve your problem, but some things I thought of you could try.

Use _integrate_forces method to handle the warp and set the position. This might not work, but worth a try and is should be simple to test.

Another thought was to freeze = true and set the freeze_mode = FreezeMode .FREEZE_MODE_STATIC before warping the body, then unfreezing afterwards freeze = false (also you can probably set the freeze_mode via the inspector as you don’t need to keep changing that)

1 Like

Thanks I tried setting freeze = true before changing position but that actually broke the physics movement for me as well. But changing global_position instead of position seems to be working so far for me not sure if the issue will crop back up later

1 Like