trying to use onready var to start a raycast to play a animation for a npc but even though the ray works it wont play the animation
code: extends Node3D enum { Attack1, Death1, Idle, Pose, Walk } var state = Idle onready var raycast = $RayCast3D onready var ap = $"maxdamage_zombie-low-poly" func _ready(): pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if raycast.is_colliding(): state = Attack1 else: state = Idle match state: Attack1: ap.play("Attack1") Death1: ap.play("Death1") Idle: ap.play("Idle") Pose: ap.play("Pose") Walk: ap.play("Walk") Explanation/Alternative simple answer on how to fix the code in a beginner/intermediate level explanationyour text
1 Answer
I fixed this issue by putting a "@" in front of onready.
@onready var raycast = $RayCast3D "onready" without the "@" seemed to break for me after upgrading to Godot 4.
0