Files
2D_Game_test/PhysicsObjects/HandStatue/HandStatue.gd
2023-01-30 17:52:27 -05:00

28 lines
834 B
GDScript

extends RigidBody2D
@onready var rigid_body = get_node(".")
@onready var last_velocity:Vector2 = Vector2(0,0)
@onready var current_player:CharacterBody2D = null
@export var initial_impulse:Vector2 = Vector2(0,0)
# Called when the node enters the scene tree for the first time.
func _ready():
print("Statue Ready!")
if initial_impulse != Vector2.ZERO:
rigid_body.apply_central_impulse(initial_impulse)
func _on_body_entered(body):
print("body entered! ")
if body.is_in_group("player"):
print("Player collided!")
current_player = body
current_player.player_hit.is_player_hit = true
current_player.player_hit.hit_velocity = last_velocity
if last_velocity.x > 50 or last_velocity.y < -50 or last_velocity.x < -50 or last_velocity.y > 50:
current_player.health_changed_func(-1)
rigid_body.set_sleeping(true)