Godot Version
v4.4.stable.official.4c311cbee
Question
On my game’s world scene I have a crop where seeds are planted and a plant should grow over time. My current and first thought is to assign different MeshInstance3D
to the same scene and show/hide the correct one.
In example I have wheat, I have created a scene for it with 4 MeshInstance3D
, all of them are just 4 CylinderMesh
of different heights and colors called Mesh0, Mesh1, Mesh2, Mesh3.
Into the script assigned to the Wheat.tscn I have this code:
extends Plant
class_name Wheat
@onready var mesh0 = $Mesh0
@onready var mesh1 = $Mesh1
@onready var mesh2 = $Mesh2
@onready var mesh3 = $Mesh3
func _ready() -> void:
mesh1.visible = false
mesh2.visible = false
mesh3.visible = false
await get_tree().create_timer(3.0).timeout
mesh0.visible = false
mesh1.visible = true
await get_tree().create_timer(3.0).timeout
mesh1.visible = false
mesh2.visible = true
await get_tree().create_timer(3.0).timeout
mesh2.visible = false
mesh3.visible = true
The code could probably be better, but at the moment I want to understand if I’m on the right track or if there’s a better way to achieve my goal.
Do you have suggestions on how to proceed?