Merge branch 'master' of https://git.sjkillen.ca/sjkillen/ABGJ-23
This commit is contained in:
commit
8465f2eadb
|
@ -13,8 +13,8 @@ var task = "idle"
|
|||
|
||||
@export var walk_speed = 0.5
|
||||
|
||||
# Rate at which character corrects their direction after going off course (percentage).
|
||||
@export var dir_correction_rate = 0.95
|
||||
# Rate at which character corrects their direction after going off course (decimal percentage).
|
||||
@export var spin_speed = 0.50
|
||||
|
||||
# Margin of accuracy to which the character will correct their direction when off course (radians).
|
||||
@export var dir_accuracy = deg_to_rad(0.1)
|
||||
|
@ -36,17 +36,17 @@ func _process(delta):
|
|||
"idle":
|
||||
task = rng.randf_range(0, 100)
|
||||
|
||||
# 3% chance to walk somewhere.
|
||||
# Chance to walk somewhere.
|
||||
if task <= walk_chance:
|
||||
task = "walk"
|
||||
target_location_xz = global_transform.origin * Vector3(1, 0, 1) + (direction_xz * 16)
|
||||
# 6% chance to rotate.
|
||||
# Chance to rotate.
|
||||
elif task > walk_chance and task <= (walk_chance + spin_chance):
|
||||
task = "spin"
|
||||
var rotation_angle = rng.randf_range(-2*PI, 2*PI)
|
||||
var rotation_vector = Vector3(cos(rotation_angle), 0, sin(rotation_angle))
|
||||
target_direction_xz = direction_xz + rotation_vector
|
||||
# 90% chance to idle.
|
||||
# Chance to idle.
|
||||
elif task > (spin_chance + walk_chance):
|
||||
task = "idle"
|
||||
|
||||
|
@ -57,7 +57,7 @@ func _process(delta):
|
|||
# Continue to correct direction to within a margin of dir_accuracy degrees.
|
||||
if direction_xz.angle_to(target_direction_xz) >= dir_accuracy:
|
||||
# Rotate towards destination at specified percentage rate.
|
||||
rotate_y(direction_xz.angle_to(target_direction_xz) * dir_correction_rate)
|
||||
rotate_y(direction_xz.angle_to(target_direction_xz) * spin_speed)
|
||||
|
||||
if location_xz.distance_to(target_location_xz) <= (Vector2(direction_xz.x, direction_xz.z) * walk_speed).length():
|
||||
target_direction_xz = direction_xz
|
||||
|
@ -65,9 +65,12 @@ func _process(delta):
|
|||
task = "idle"
|
||||
|
||||
"spin":
|
||||
task = "idle"
|
||||
|
||||
|
||||
if direction_xz.angle_to(target_direction_xz) >= dir_accuracy:
|
||||
# Rotate towards destination at specified percentage rate.
|
||||
rotate_y(direction_xz.angle_to(target_direction_xz) * spin_speed)
|
||||
else:
|
||||
task = "idle"
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
|
|
Loading…
Reference in New Issue