0 votes

I have two instanced scenes (A and B as children of Main Scene), now A is instanced in the Editor while B is instanced in the Script of Main. In the Script of B, I want to add behavior for it to look at A. Without adding code in the Main scene, how can I implement this if it is possible?

(No signals if possible, A and B are instanced siblings, and they are both kinematic bodies)
GDScript is nice but if it is in C# it will be more helpful, thanks!

Godot version 3.4.4
in Engine by (23 points)

1 Answer

+1 vote
Best answer

What about that script for Node B:

Spatial a = GetNode<Spatial>("../A");
LookAt(a.GlobalTransform.origin, Vector3.Up);

"../" will get the parent node, and "A" will get it's child.

by (1,079 points)
selected by
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.