diff --git a/project.godot b/project.godot index f2b8dd6..bdaed21 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="First Person Test" config/tags=PackedStringArray("fps") -run/main_scene="uid://f7e0v1r6ra6c" +run/main_scene="uid://bk4pn4k7n51ux" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="uid://6svuq1l83al5" diff --git a/scripts/enemy_stunned.gd b/scripts/enemy_stunned.gd index fdbd91e..be6f216 100644 --- a/scripts/enemy_stunned.gd +++ b/scripts/enemy_stunned.gd @@ -3,10 +3,44 @@ class_name EnemyStunned @export var stunned_stars : Node -func _Enter(): +var move_direction : Vector3 +var scan_direction : float + +var wander_time : float +var scan_time : float + +const WANDER_AMT = 50 +const TURRET_TURN_AMT : float = 180.0 + +func Enter(): + super() + print("ENEMY STUNNED") if stunned_stars: stunned_stars.visible = true + randomize_wander() func _Exit(): if stunned_stars: stunned_stars.visible = false + +func Update(delta): + if wander_time > 0: + wander_time -= delta + else: + randomize_wander() + +func Physics_Update(delta : float): + if enemy: + var destination = enemy.nav_agent.get_next_path_position() + var local_destination = destination - enemy.global_position + var direction = local_destination.normalized() + if enemy.global_position.distance_to(local_destination) > 1: + enemy.velocity = direction * move_speed + enemy.global_rotation.y += delta + +func randomize_wander(): + var x = randf_range(-WANDER_AMT,WANDER_AMT) + var z = randf_range(-WANDER_AMT,WANDER_AMT) + move_direction = enemy.global_position + Vector3(x,0,z) + enemy.nav_agent.set_target_position(move_direction) + wander_time = randf_range(1,3) diff --git a/scripts/rocket.gd b/scripts/rocket.gd index b857617..fa4d773 100644 --- a/scripts/rocket.gd +++ b/scripts/rocket.gd @@ -45,5 +45,6 @@ func explode(): body.recoil.add_recoil(Vector3(1,.1,.1),10,10) if body.has_method("hit") and !body.is_in_group("player"): body.hit(1) - if body is Enemy: - body.stun() + if body.is_in_group("enemy"): + if body.has_method("stun"): + body.stun() diff --git a/scripts/spider.gd b/scripts/spider.gd index e0c0173..3349079 100644 --- a/scripts/spider.gd +++ b/scripts/spider.gd @@ -105,16 +105,6 @@ func _on_postfire_timer_timeout(): postfire_timer.start() -func _on_knocked_timer_timeout(): - print("KNOCK TIMEOUT") - velocity = Vector3(0,0,0) - knocked = false - - -func _on_stunned_timer_timeout(): - print("STUN TIMEOUT") - stunned = false - func fire(barrel): var instance_bullet = bullet.instantiate() instance_bullet.position = barrel.global_position