![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Zync |
How can i make objects rise??? fx Lava or water?
Have you looked at any documentation/tutorials? If you simply want it to rise up you can use
translate(Vector3(0, rise, 0))
In future look in the inspector for the property you need or look up a method that does the job.
Magso | 2019-06-09 15:21
it doesnt work… iam really a noob at programming
Zync | 2019-06-10 10:38
To make that work you should have this.
#The variable for rising speed.
var rise : float
#float means it's a decimal number.
func _process(delta):
#This function runs every frame like void update in unity or event tick in unreal.
translate(Vector3(0, rise, 0))
#This will move the node 'rise' units every frame.
translate(Vector3(0, rise * delta, 0))
#Same but multiplied by delta, delta is the time between this frame and the last frame making the movement smoother and slower.
get_node("../anotherNode").translate(Vector3(0, rise, 0))
#This moves "anotherNode"
Magso | 2019-06-10 11:32
it says: error(10, 15): No constructer of ‘Vector2’ matches the signature ‘Vector2( int, float, int)’.
if it is a 2d game i have to change the vector from vector3 to vector2 right?
And should i edit the “…/anotherNode”?
Zync | 2019-06-10 15:54
Yes use Vector2
for 2D. Also you only have to pick one of the translate statements, I gave you different examples. If the script is on the node you want to move just use translate
, if the script is on a separate node it needs to know which node to reference to using get_node("../nameOfNode")
and translate it.
Magso | 2019-06-10 16:25
translate(Vector2(0, rise))
Magso | 2019-06-10 16:55