The most rudimentary teleportation/blink in 3D platformer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lukamrko

So I want to make the most rudimentary way for to player to teleport or rather blink in the Godot. So far my idea is to add child node (i tried with the area) to my player that is set in front of the player as seen in the image.
enter image description here

And this is the code that I tried to use to test even more basic type of teleportation:
enter image description here

This code doesn’t work even slightly but it doesn’t cause me any errors either (I did define player_postion as var player_position=Position3D)

So what would be the solution to teleport my player to area I put on a simple button press? For now it doesn’t need some collision check (I will try to implement that on my own).

Before I suggest anything, do you mean to say

“You want your player to teleport to the the position where your child node named (Teleport) is?”

Xian | 2019-11-05 03:13

:bust_in_silhouette: Reply From: Xian

If what you want to do is make your player to teleport to the the position where your child node named (Teleport)

if input.is_pressed(KEY_0):
    var player = get_node_or_null("PATH TO PLAYER")
    var teleportPoint  = player.get_node_or_null("Teleport").translation
    var teleport = player.translation + teleportPoint 

    player.translation = teleport 

Thanks for the help, but when I try to do that I get the following error:
enter image description here

I tried to move it from null instance but I don’t really understand on how to do it. Can you help again?

lukamrko | 2019-11-05 21:01

:bust_in_silhouette: Reply From: lukamrko

OK I have managed to make it work, but I will need to add some constraint.
The code is:
#TELEPORT if Input.is_key_pressed(KEY_ALT): var teleportPoint=to_global(get_node("Teleport").translation) translation = teleportPoint