very happy with idle script now
This commit is contained in:
@@ -48,7 +48,7 @@ func search_for_suspicious_sounds():
|
||||
enemy.player_last_seen = null
|
||||
Transitioned.emit(self,"search")
|
||||
|
||||
func rotate_to_face2D(object,target,delta,turn_speed):
|
||||
func rotate_to_face2D(object,target,target_offset_angle,delta,turn_speed):
|
||||
#to allow both nodes and positions to be passed to this function, test the target and use Vector3 coords
|
||||
var target_transformed
|
||||
if target == null:
|
||||
@@ -61,21 +61,22 @@ func rotate_to_face2D(object,target,delta,turn_speed):
|
||||
var pos2d = Vector2(object.global_position.x,object.global_position.z)
|
||||
var target_pos2d = Vector2(target_transformed.x,target_transformed.z)
|
||||
var direction = (pos2d - target_pos2d)
|
||||
return lerp_angle(object.rotation.y,atan2(direction.x,direction.y),delta * turn_speed)
|
||||
|
||||
func clear_point_of_interest():
|
||||
enemy.point_of_interest = null
|
||||
return lerp_angle(object.global_rotation.y,atan2(direction.x,direction.y) + deg_to_rad(target_offset_angle),delta * turn_speed)
|
||||
|
||||
func move_to_nav_point(delta):
|
||||
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(destination) > 1:
|
||||
enemy.velocity = direction * move_speed
|
||||
enemy.global_rotation.y = rotate_to_face2D(enemy,destination,delta,body_turn_speed)
|
||||
enemy.velocity = direction * move_speed
|
||||
enemy.global_rotation.y = rotate_to_face2D(enemy,destination,0,delta,body_turn_speed)
|
||||
|
||||
func turret_look(delta):
|
||||
enemy.turret_look.global_rotation.y = rotate_to_face2D(enemy.turret_look,move_target,delta,50)
|
||||
func turret_look(target,delta):
|
||||
enemy.turret_look.global_rotation.y = rotate_to_face2D(enemy.turret_look,target,0,delta,turret_speed)
|
||||
|
||||
|
||||
func turret_scan_look(target,scan_direction,delta):
|
||||
enemy.turret_look.global_rotation.y = rotate_to_face2D(enemy.turret_look,target,scan_direction,delta,turret_speed)
|
||||
|
||||
|
||||
func debug_marker(target_pos):
|
||||
if enemy.debug_tools:
|
||||
|
||||
Reference in New Issue
Block a user