0 votes

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).

in Engine by (16 points)

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?"

2 Answers

0 votes

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 
by (271 points)

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?

0 votes

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

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.