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

27 lines
789 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-19 22:22:16 +02:00
if not $RayBottomLeft.is_colliding() or $RayLeft.is_colliding():
2022-07-18 03:28:10 +02:00
velocity.x = speed
2022-07-19 22:22:16 +02:00
if not $RayBottomRight.is_colliding() or $RayRight.is_colliding():
2022-07-18 03:28:10 +02:00
velocity.x = -speed
2022-07-17 14:24:15 +02:00
func stomped_on_head():
if not $RayPlayerLeft.is_colliding() and not $RayPlayerRight.is_colliding():
health = 0
$Sprite.animation = "stomped"
$StampedSound.play()
2022-07-19 18:11:23 +02:00
func _on_PlayerCollision(body):
if $Collision.disabled == false:
if body.velocity.x > 0:
body.monster_hit(-speed, damage)
elif body.velocity.x < 0:
body.monster_hit(speed, damage)
elif velocity and velocity.x > 0:
body.monster_hit(speed, damage)
elif velocity and velocity.x < 0:
body.monster_hit(-speed, damage)