How to get 3d position and use it to change variable

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

How would I get the 3d position and use it to change a variable?

get_node("/root/Spatial/sfvm390wg").get_translation(by,bx,bz))
by = posdy
bx =posdx
bz = posdz

So are you trying to store the position or change the translation with variables? Because it looks like you’re trying to change the variables you just set.

xofox | 2019-10-02 15:50

I’m trying to get the position of object every frame and use it to store variables of position
that are changing.

0sait05 | 2019-10-02 15:55

:bust_in_silhouette: Reply From: xofox

The first thing that jumps out at me is that you set the variables by, bx, and bz and then change them into something else. Try out:

       get_node("/root/Spatial/sfvm390wg").get_translation(by,bx,bz))
var posdy = by
var posdx = bx
var posdz = bz

that makes more sense to me. I deal mainly with 2D and I’m not sure what the context of your code is so I hope that helps.