enemy stun is working now, needs timeout
This commit is contained in:
@@ -12,7 +12,7 @@ config_version=5
|
|||||||
|
|
||||||
config/name="First Person Test"
|
config/name="First Person Test"
|
||||||
config/tags=PackedStringArray("fps")
|
config/tags=PackedStringArray("fps")
|
||||||
run/main_scene="uid://f7e0v1r6ra6c"
|
run/main_scene="uid://bk4pn4k7n51ux"
|
||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||||
config/icon="uid://6svuq1l83al5"
|
config/icon="uid://6svuq1l83al5"
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,44 @@ class_name EnemyStunned
|
|||||||
|
|
||||||
@export var stunned_stars : Node
|
@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:
|
if stunned_stars:
|
||||||
stunned_stars.visible = true
|
stunned_stars.visible = true
|
||||||
|
randomize_wander()
|
||||||
|
|
||||||
func _Exit():
|
func _Exit():
|
||||||
if stunned_stars:
|
if stunned_stars:
|
||||||
stunned_stars.visible = false
|
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)
|
||||||
|
|||||||
@@ -45,5 +45,6 @@ func explode():
|
|||||||
body.recoil.add_recoil(Vector3(1,.1,.1),10,10)
|
body.recoil.add_recoil(Vector3(1,.1,.1),10,10)
|
||||||
if body.has_method("hit") and !body.is_in_group("player"):
|
if body.has_method("hit") and !body.is_in_group("player"):
|
||||||
body.hit(1)
|
body.hit(1)
|
||||||
if body is Enemy:
|
if body.is_in_group("enemy"):
|
||||||
body.stun()
|
if body.has_method("stun"):
|
||||||
|
body.stun()
|
||||||
|
|||||||
@@ -105,16 +105,6 @@ func _on_postfire_timer_timeout():
|
|||||||
postfire_timer.start()
|
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):
|
func fire(barrel):
|
||||||
var instance_bullet = bullet.instantiate()
|
var instance_bullet = bullet.instantiate()
|
||||||
instance_bullet.position = barrel.global_position
|
instance_bullet.position = barrel.global_position
|
||||||
|
|||||||
Reference in New Issue
Block a user