0 votes

if I have a 2 kinematicbody2d's I want one to have the position of the other body so it can teleport to it, please help.

in Engine by (25 points)

1 Answer

0 votes

You get the node via its path and then access the position property.

by (6,296 points)

I did, this is what I did:

var instance_object = preload("path of scene")

func _physics_process(delta):
self.position = instance_object.position

it doesn't work and gives me an error, please help.

Did you instance the object? What is the error?

I have a main node containing two players I want to access the player's position so one can teleport to the other I am having trouble and errors like :

" invalid get index 'position' on 'base packed scene' ".

You need to instance the object first.

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 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 webmaster@godotengine.org with your username.