19 lines
480 B
GDScript
19 lines
480 B
GDScript
extends Spatial
|
|
|
|
var treeInitialPos = []
|
|
const carSpeed = 30.0
|
|
|
|
|
|
func _ready():
|
|
InitTreeStartPosition()
|
|
|
|
|
|
func InitTreeStartPosition():
|
|
for i in $TreeArray.get_child_count():
|
|
treeInitialPos.push_back($TreeArray.get_child(i).translation.z)
|
|
|
|
func _process(delta):
|
|
for i in $TreeArray.get_child_count():
|
|
$TreeArray.get_child(i).translation.z -= carSpeed * delta
|
|
if $TreeArray.get_child(i).translation.z <= - 1.0:
|
|
$TreeArray.get_child(i).translation.z = treeInitialPos[i]
|