forked from team-sg/hero-mark-2
23 lines
574 B
GDScript
23 lines
574 B
GDScript
extends KinematicBody2D
|
|
|
|
var velocity: Vector2 = Vector2.ZERO
|
|
|
|
func _physics_process(delta):
|
|
if not is_on_floor():
|
|
#Gravity
|
|
velocity.y = 100.0
|
|
velocity.x = 0.0
|
|
else:
|
|
velocity.y = 0.0
|
|
move_and_slide(velocity,Vector2.UP)
|
|
velocity.x = 0.0
|
|
|
|
func push(amount: float):
|
|
velocity.x = amount
|
|
|
|
func _on_Hitbox_area_entered(area):
|
|
# do not squish if in "blocks_squash" group
|
|
if area.is_in_group("enemy_hitbox") and not area.is_in_group("blocks_squash"):
|
|
var enemy = area.get_owner()
|
|
if enemy.global_position.y > global_position.y and velocity.y > 0:
|
|
enemy.die()
|