Teleporters

In Valve Inc.'s Portal series, you shoot portals to warp through. You save your momentum going through. I want to duplicate this for a game mechanic in 2D.How can I achieve this momentum-saving effect, and how can I warp depending on the angle of entry?(example: if I drop DOWN into the warp, I go DOWN. If I launch into the warp from the BOTTOM LEFT, I will fly out of the other on the TOP RIGHT).
Comments
Warp1 changes real attributes warp1x and warp1y to it's current position--warp2 does likewise to warp2x and warp2y.
Upon player hitting warp1, change self.position.x and y to warp2x and y. Simple so far, right?
But let's say you want the actor in the warphole for a second--not instantly. Add to the player's events: when player hits warp1, change real attribute playervelx and playervely to player.motion.veloicty.linear x or y. Then, change velocity x and y to 0 for, say, 1 second. After 1 second, (when it's moved to warp2x/y) change attribute velocity x and y to playervelx and playervel y (you're just saving the motion--then stopping it---then restarting it again).
So:
Make 2 game attributes: actorxv and acoryv
Have a rule in the actor:
When actor recieves event colide with actor of type portal
change attribute game.actorxv to self.motion.linear velocitx
change attribute game.actoryv to self.motion.linear velocity
then do teleport (however you want to do this)
and then a rule: when teleport is done
change attribute self.motion.linear velocitx to game.actorxv
change attribute self.motion.linear velocity to game.actoryv
But when you change the x and y position to teleport, the velocity the actor had is probably the same so you don't need these rules.
Hope this helps, I did not test it
Lump Apps and My Assets