Files
fps_project_1/scripts/rat.gd
2024-07-28 00:36:42 -05:00

28 lines
858 B
GDScript

extends RigidBody3D
@onready var anim_player = $AnimationPlayer
@export var dead_rat : Resource
var end_hole
var control_node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if end_hole != null:
var move_direction = (end_hole.global_position - self.position).normalized()
position += transform.basis * move_direction * delta * 7
self.look_at(end_hole.position,Vector3.UP)
func breaking(bullet_velocity):
var spawn_broken = dead_rat.instantiate()
spawn_broken.position = global_position
spawn_broken.transform.basis = global_transform.basis
spawn_broken.rotation = rotation
var pieces = spawn_broken.get_children()
get_tree().get_root().add_child(spawn_broken)
queue_free()