Files
DailyDungeon/Scripts/gold.gd

25 lines
842 B
GDScript

extends RigidBody3D
class_name Gold
var amount = 1
var follow_target
var spawn_out = false
const SPAWN_OUT_SIZE = 4.0
const SPAWN_OUT_HEIGHT = 14.0
func _process(delta: float) -> void:
if follow_target != null:
if spawn_out:
#if global_position.y < SPAWN_OUT_HEIGHT: REMOVED BECAUSE I DIDN'T LIKE THE LOOK, LEAVING FOR NOW IN CASE I WANT TO MAKE A DIFFERENT EFFECT HAPPEN
#linear_velocity = Vector3(0,10,0)
#else:
follow_target.gold += amount
queue_free()
else:
if global_position.distance_to(follow_target.global_position) < .5:
spawn_out = true
else:
var direction_to_player = global_position.direction_to(follow_target.global_position)
var distance_to_player = global_position.distance_to(follow_target.global_position)
linear_velocity = direction_to_player * (5 + distance_to_player * 3)