0 votes

HI All. I'm struggling with transforms again... I have a kinematic body 3D and i want to spawn 2 other kinematic bodies and set their positions to flank the main body, relative to its position in global space as well as its current direction. The behaviour i'm going for is something like if the spawned nodes were added as children of the main kinematic body and offset by x units on either side of it. For other reasons I don't want them parented to the main node though.

in Engine by (512 points)

1 Answer

0 votes

Hi,
you can use Spatial.to_global ()
https://docs.godotengine.org/en/stable/classes/class_spatial.html?highlight=spatial#class-spatial-method-to-global

Assuming this script runs in focus of the main object and the flanking objects are in global space and not transformed by a parenting object

leftFlankObject.translation = to_global( Vecto3(-1,0,0) )    
rightFlankObject.translation = to_global( Vecto3(1,0,0) )

not tested!

by (4,084 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.