0 votes

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

Godot version 3.4.4.stable
in Engine by (26 points)

1 Answer

+1 vote
Best answer

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.

by (21,716 points)
selected by

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

thank you so much!!!!

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.