Re: 3d Transforms. How to spawn nodes that would flank a 3d node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

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.

:bust_in_silhouette: Reply From: klaas

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!