Teleporters

svnsvn Member Posts: 445
edited November -1 in Working with GS (Mac)
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

  • jb15jb15 Member Posts: 602
    You have three actors: 1. player 2. warp1 and 3. warp2

    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).
  • LumpAppsLumpApps Member Posts: 2,881
    When you use anything but interpolate to move your actor your actor should have an x and y velocity. You can save these attributes in a game attribute named for example actorxv and actoryv at the moment the actor collides with the portal. When your actor has teleported you can set its x and y velocity to the saved values.

    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 ;)
Sign In or Register to comment.