20 lines
647 B
GDScript
20 lines
647 B
GDScript
extends "res://objects/characters/monsters/monster.gd"
|
|
|
|
func _process(delta):
|
|
if velocity != null:
|
|
if not $RayBottomLeft.is_colliding():
|
|
velocity.x = speed
|
|
if not $RayBottomRight.is_colliding():
|
|
velocity.x = -speed
|
|
if $RayPlayerLeft.is_colliding():
|
|
var collider = $RayPlayerLeft.get_collider()
|
|
collider.monster_hit(-speed, DAMAGE)
|
|
if $RayPlayerRight.is_colliding():
|
|
var collider = $RayPlayerRight.get_collider()
|
|
collider.monster_hit(speed, DAMAGE)
|
|
|
|
func stomped_on_head():
|
|
if not $RayPlayerLeft.is_colliding() and not $RayPlayerRight.is_colliding():
|
|
health = 0
|
|
$Sprite.animation = "stomped"
|
|
$StampedSound.play()
|