quite incredible
This commit is contained in:
parent
94ed6c6c68
commit
b6daa18e6c
5 changed files with 113 additions and 0 deletions
31
objects/enemy/uncanny_cat.gd
Normal file
31
objects/enemy/uncanny_cat.gd
Normal file
|
@ -0,0 +1,31 @@
|
|||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
|
||||
export var acceleration: float = 8.0
|
||||
export var max_speed: float = 16.0
|
||||
|
||||
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
onready var player: Node2D = get_tree().get_nodes_in_group("player")[0]
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not is_instance_valid(player):
|
||||
return
|
||||
|
||||
var target = (player.global_position - global_position).normalized()
|
||||
velocity += target * acceleration * delta
|
||||
velocity = velocity.clamped(max_speed)
|
||||
|
||||
global_position += velocity * delta
|
||||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
#Kill player
|
||||
if area.is_in_group("player_hitbox"):
|
||||
area.get_parent().die()
|
||||
$Jumpscare.visible = true
|
||||
$JumpscareSound.play()
|
||||
var tween = create_tween()
|
||||
tween.tween_property($Jumpscare, "visible", false, 0).set_delay(1.7)
|
Loading…
Add table
Add a link
Reference in a new issue