Hi! I am completely newbie to Godot and all coding stuff. I want to create some kind of instant teleportation of character from it's position to another like that: when I click mouse on button (it has Area with Signal script) character should instantly change his position to position of other object ("portal_2" unseen for player).
I use Godot 4. I tried to script this but can't understand how to make it. My last attempt of Signal script looks so:
@onready var character = get_parent().get_node("char_body")
@onready var portal_2 = get_node("portal_2")
var char_position = character.get_position()
var portal_2_pos = portal_2.get_position()
func _on_area_3d_input_event(camera, event, position, normal, shape_idx):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed == true:
char_position = portal_2_pos
Please, explain someone. what are my mistakes and how to do what I want.