initial uncanny work
This commit is contained in:
parent
ab2d42ccd9
commit
8165cda61c
11 changed files with 132 additions and 12 deletions
26
objects/uncanny_cat.gd
Normal file
26
objects/uncanny_cat.gd
Normal file
|
@ -0,0 +1,26 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
|
||||
@export var acceleration: float
|
||||
@export var speed: float
|
||||
@export var vertical_speed: float
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var target: Node3D = null
|
||||
for node in get_tree().get_nodes_in_group(&"chaser_target"):
|
||||
if node is Node3D:
|
||||
if not target or (
|
||||
global_position.distance_squared_to(node.global_position) <
|
||||
global_position.distance_squared_to(target.global_position)
|
||||
):
|
||||
target = node
|
||||
|
||||
if target:
|
||||
velocity += global_position.direction_to(target.global_position) * acceleration * delta
|
||||
velocity = velocity.limit_length(speed)
|
||||
velocity.y = (target.global_position.y - global_position.y) * vertical_speed
|
||||
|
||||
var col = move_and_collide(velocity * delta)
|
||||
if col:
|
||||
velocity = velocity.bounce(col.get_normal())
|
Loading…
Add table
Add a link
Reference in a new issue