Final touches
This commit is contained in:
8
Mob.gd
8
Mob.gd
@@ -5,12 +5,12 @@ extends CharacterBody3D
|
||||
|
||||
signal squashed
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta):
|
||||
move_and_slide()
|
||||
|
||||
func initialize(start_position, player_position):
|
||||
# Look to the player
|
||||
look_at_from_position(start_position, player_position, Vector3.UP)
|
||||
look_at_horizontal(start_position, player_position)
|
||||
# But rotate a little bit
|
||||
rotate_y(randf_range(-PI / 4, PI / 4))
|
||||
# Set random speed
|
||||
@@ -21,6 +21,10 @@ func initialize(start_position, player_position):
|
||||
|
||||
$AnimationPlayer.speed_scale = random_speed / min_speed
|
||||
|
||||
func look_at_horizontal(start_position: Vector3, target_position: Vector3):
|
||||
var target_horizontal_position = Vector3(target_position.x, start_position.y, target_position.z)
|
||||
look_at_from_position(start_position, target_horizontal_position, Vector3.UP)
|
||||
|
||||
func squash():
|
||||
squashed.emit()
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user