I’m making a simple 2d space game. If the space ship flies off the screen to the left it should appear on the right. So think of the screen as a flattened out sphere.
The way I achieve this is by making a clone of the ship on the opposite side when it starts to leave the screen. When the clone is fully “inside” the screen again I teleport the ship to the clone position and Destroy() the clone (as suggested by this guy).
It works well, but sometimes when a clone exists and it (or the ship) is hit by a rock floating by, the ship and the clone fall out of sync. What I would like is if the clone is hit by a rock, making it drift in a different direction and have it’s rotation altered, the same forces should be applied to the ship (and vice versa).
I tried setting the rigidbody2D of the clone to the same as the ships but the property is not setable (GameObject.rigidbody2D). I also thought about writing something in the OnCollisionEnter() to set the velocity and angularvelocity of the ship manually. But I don’t know if the physics have been applied at that point and I can’t find a clear answer.
Has anyone done anything like this before?