I've been experimenting with 2D portals in my game. I have a simple script that queue_frees a ball once it enters one portal, and spawns one in in the other.
I want to preserve the velocity of the ball, so that it doesn't just have zero velocity when it comes out of the portal. For this, I used the linearvelocity of the preexisting ball before it gets queuefreed, and apply that to the new ball once it comes out of the portal.
However, this does not align with the rotation of the portal, and the ball always continues to go in whatever direction it was going in. I want to be able to have the same velocity and momentum, but come out in the direction the portal's facing.
Does anyone know a variable I could use to modify this? How can I make the 2D portals realistic?