# how to do math inside a vector3

Attention Topic was automatically imported from the old Question2Answer platform.
Asked By i dont like

i am trying to make a tween that moves a door up by 5, but because i have to reuse the script i need to make the tween relative to the coordinates of the door

``````extends StaticBody

var pressed : bool = false

func _on_button_detection_area_entered(area):
\$open.interpolate_property(
self,
"position",
Translation,
Translation() + Vector3(0,5,0), <<<<<<<<<<<<<<here
1,
Tween.TRANS_LINEAR,
Tween.EASE_OUT,
0)
``````

im attempting to use the translation and add a vector3 to it, but this appears to be not what im supposed to do as i get an error saying that the method Translation is not declared in the current class (the arrows arent actually in the code its to point it out)

if someone knows how to do math for a vector3 to make it relative to the object, please help

Reply From: kidscancode

Well, there’s nothing in StaticBody called “Translation”. There is a property called `translation` that represents the body’s position in local coordinates. It’s not a function though, so `()` would not be appropriate the second time you write it.

Also, there’s no `position` property in 3D nodes either. What you really want, to tween the position from its current value to an offset of (0, 5, 0) would be

``````\$open.interpolate_property(
self,
"translation",
null,
translation + Vector3(0,5,0),
1,
Tween.TRANS_LINEAR,
Tween.EASE_OUT,
0)
``````

`null` here just tells the tween to use the current value of the property as the starting value.

PS - don’t forget to `start()` your tween.

kidscancode | 2022-07-25 04:36

thank you so much!!!

i dont like | 2022-07-25 19:48