Flopsy/objects/characters/monsters/01/monster_01.gd

21 lines
647 B
GDScript3
Raw Normal View History

2022-07-17 14:24:15 +02:00
extends "res://objects/characters/monsters/monster.gd"
func _process(delta):
2022-07-18 03:28:10 +02:00
if velocity != null:
2022-07-17 14:24:15 +02:00
if not $RayBottomLeft.is_colliding():
2022-07-18 03:28:10 +02:00
velocity.x = speed
2022-07-17 14:24:15 +02:00
if not $RayBottomRight.is_colliding():
2022-07-18 03:28:10 +02:00
velocity.x = -speed
2022-07-17 14:24:15 +02:00
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()