How to teleport player relative to its position

Kutscher

L1: Registered
Sep 13, 2020
4
0
For example, add 10 to the players X coordinates..
I want the player to get teleported into an other room without letting him know.
I'm a beginner so please explain everything as simple as possible.
I know about trigger_teleport, but i dont know what to do with it.
 

Da Spud Lord

Occasionally I make maps
aa
Mar 23, 2017
1,339
994
When a player touches a trigger_teleport entity, ordinarily they are just teleported directly to the specified Remote Destination entity- no offset is preserved, and no matter where the player entered the trigger they always come out at the exact same spot, facing the same direction as the Remote Destination entity.

However, this changes if we specify a second entity as the Local Destination Landmark. When a player touches a trigger_teleport with a Local Destination Landmark, their offset from the Local Destination Landmark is recorded. The player is then teleported to the Remote Destination, but with a twist: Their actual destination will be offset from the Remote Destination, with this offset being equivalent to the player's original offset from the Local Destination Landmark. The player will also be facing whichever direction they were originally facing, instead of facing the Remote Destination's direction. The below diagram, which was taken from this page, illustrates this concept well:
448px-Landmark_tele.png

Effectively, this teleports the player relative to themselves: Their new position is their old position + the offset between the Local Destination Landmark and the Remote Destination.

As an example, let's say that I want to make a hallway that changes color as the player walks down it. Rather than actually change the textures of the brushes however, I'll instead just be teleporting the player to another hallway with an identical shape, but with a different texture for the walls. Like you, I want to make the teleportation seamless so the player doesn't realize they've been moved to a different hallway. I'll start by building the first hallway as seen in the diagram below. Then I'll choose an arbitrary point in or near the room, and place an info_teleport_destination entity there which I'll name "landmark".
upload_2020-9-13_20-57-2.png
To make the second hallway, I'll select everything in this hallway (including landmark) and copy it all. In this copy, I'll change the textures on the walls to be a different color, and rename the copy of landmark to something else, such as "destination".
upload_2020-9-13_21-0-9.png
Notice how destination's position in the blue room is identical to landmark's position in the red room. Last step is to create the trigger_teleport, which I'll represent in the diagram with this yellow square. I then configure the trigger_teleport's settings as shown at the top of the diagram.
upload_2020-9-13_21-9-7.png
I also want to make sure that the Clients flag is checked in the trigger_teleport, otherwise the trigger_teleport won't teleport players when they touch it (this flag might be named slightly differently in your view):
upload_2020-9-13_21-13-24.png

Thus, when any player (represented by the black line in the diagram) attempts to cross the red room, they will be seamlessly teleported to the blue room.

If I want players in the blue room to be able to return to the red room, I can add a second trigger_teleport in the blue room with reversed settings as shown at the bottom of this diagram:
upload_2020-9-13_21-15-46.png

That's all you need to know! If you have any more questions, just ask.
 

Kutscher

L1: Registered
Sep 13, 2020
4
0
Is it possible to make the same thing but with a button instead of the trigger?
 

Da Spud Lord

Occasionally I make maps
aa
Mar 23, 2017
1,339
994
Not directly. What I would advise is have the trigger_teleport start disabled, and then enable the trigger_teleport when the button is pressed.