Want to make a character move from one point to another instantly? Maybe you want to teleport your player to another area once they complete a mission? This article will help you instantly move your character from one area to another.
- Open the Asset library and search for a playable character premade. For this example, use the Johannes Platformer Player.
- In the Asset library, also search for Teleporter Pads under the Premades section and add them to your scene.
- Place them in different places.
- Playtest and walk with your character towards one. It will take you to the other!
And now you have two teleporters that work with each other to move your character to a different area. They even play an effect and make your character spin!
teleport_premades.mp4
- Add a player from the Asset library to your scene. For this example, use the Platformer Player.
- Add a GPS Symbol from the Asset library, along with a Circle Marquee. Place them in separate areas.
- Add the following nodes to your scene:
- Mover
- Value Inspector
- Vector Math Operator
- Select the GPS Symbol, and go to the Advanced details panel. Here, you can add a Collision Detector node by tapping on the plus symbol next to Object.
- Drag a link from On Collision Start to Mover - Execute.
- Select the Mover node, expand the details panel, and toggle on Teleport.
- Still in the Mover node, set Operation to Set Position, and also drag a link from Target to the player character.
- Select the Value Inspector, and drag a link from Source to the Circle Marquee.
- Now, drag a link from Value Output to Vector Math Operator - Vector 1.
- Select the Vector Math Operator and change the Y position under Vector 2 to 1.0. This will make it so that the character spawns above ground.
- Drag a link from Value Output to Mover - Vector.
- Now playtest and walk your character to the GPS Symbol. It should instantly be teleported to the new area.
teleport_logic.mp4
- Indicate to the player that you are moving them to a new area. It's good to keep your users informed so they don't get confused! This can be done by using something similar to the Teleporter Pads: effects, sounds, and/or animations.
Pro Creator Tip: Make sure that you account for the position of the object you are teleporting the player to. Like done in the example, a Vector Math Operator helps to position the player higher so they don't spawn in the ground.
Explore the following links for more related content and additional resources. These pages contain valuable information that complements what you’ve just read.
Nodes
Transforming Objects
Reading Values