Files
fps_project_1/scripts/rat.gd

28 lines
832 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
self.set_linear_velocity(move_direction * 1)
#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()