he is not doing his job and just runs in place like an idiot
extends CharacterBody3D
var asleep = true
var animations = ["idle1", "idle2"]
var deaths = ["die01", "die02"]
var health = 60
var player:CharacterBody3D
var hasdied = false
const SPEED = 5.0
func _process(delta: float) -> void:
if health <= 0:
if !hasdied:
$runner/AnimationPlayer.stop()
hasdied = true
$runner/Armature/Skeleton3D/BoneAttachment3D/Die.play()
$runner/AnimationPlayer.play(deaths.pick_random())
else:
if !hasdied:
if asleep:
velocity = Vector3.ZERO
if !$runner/AnimationPlayer.is_playing():
$runner/AnimationPlayer.play(animations.pick_random())
else:
if !$runner/AnimationPlayer.is_playing():
$NavigationAgent3D.target_position = player.global_position
$runner/AnimationPlayer.play("run_001")
func _physics_process(delta: float) -> void:
velocity += get_gravity() * delta
func _on_detection_range_body_entered(body: Node3D) -> void:
if body.is_in_group("player"):
$runner/AnimationPlayer.stop()
$runner/Armature/Skeleton3D/BoneAttachment3D/Scream.play()
asleep = false
player = body
func hurt(amt:int):
health -= amt
This is not helpful information what so ever.
What do you expect to happen vs. what actually happens? How are your nodes set up? Do you get any error or warning messages?
extends CharacterBody3D
var asleep = true
var animations = ["idle1", "idle2"]
var deaths = ["die01", "die02"]
var health = 60
var player:CharacterBody3D
var hasdied = false
const SPEED = 5.0
func _process(delta: float) -> void:
if health <= 0:
if !hasdied:
$runner/AnimationPlayer.stop()
hasdied = true
$runner/Armature/Skeleton3D/BoneAttachment3D/Die.play()
$CollisionShape3D.disabled = true
$runner/AnimationPlayer.play(deaths.pick_random())
func _physics_process(delta: float) -> void:
if !hasdied:
velocity += get_gravity() * delta
if health > 0:
if !hasdied:
if asleep:
velocity = Vector3.ZERO
if !$runner/AnimationPlayer.is_playing():
$runner/AnimationPlayer.play(animations.pick_random())
else:
if !$runner/AnimationPlayer.is_playing():
$NavigationAgent3D.target_position = player.global_transform.origin
var current = global_transform.origin
var nextpos = $NavigationAgent3D.get_next_path_position()
var direction = (nextpos - current).normalized()
velocity = direction * SPEED
$runner/AnimationPlayer.play("run_001")
move_and_slide()
func _on_detection_range_body_entered(body: Node3D) -> void:
if body.is_in_group("player"):
$runner/AnimationPlayer.stop()
$runner/Armature/Skeleton3D/BoneAttachment3D/Scream.play()
asleep = false
player = body
func hurt(amt:int):
health -= amt
```after tweaking and refactoring it it still doesn't work