45 lines
1.1 KiB
GDScript
45 lines
1.1 KiB
GDScript
extends Spatial
|
|
|
|
onready var active_physics_node: Spatial = $OnFootPhysics
|
|
|
|
export var can_glide: bool = false
|
|
export var can_float: bool = false
|
|
|
|
func _ready():
|
|
Util.player = self
|
|
|
|
func is_on_foot():
|
|
return active_physics_node == $OnFootPhysics
|
|
|
|
func is_ground_walking():
|
|
return is_on_foot() and $OnFootPhysics/Floor.is_on_floor and $MovementInput.input_xz != Vector2.ZERO
|
|
|
|
func is_ground_sprinting():
|
|
return is_ground_walking() and $MovementInput.sprinting
|
|
|
|
func camera():
|
|
return $"Smoothing/CameraController/Rotation/Camera"
|
|
|
|
func camera_position() -> Vector3:
|
|
return camera().global_transform.origin
|
|
|
|
func set_physics_node(node: Spatial):
|
|
if active_physics_node == node:
|
|
return
|
|
|
|
$Smoothing.target = NodePath("../" + node.name)
|
|
node.global_transform = active_physics_node.global_transform
|
|
active_physics_node = node
|
|
|
|
func objective_distance() -> float:
|
|
return $ObjectiveTracker.objective_distance
|
|
|
|
func _process(_delta):
|
|
if Dialogic.get_variable("enable_glide") == "true":
|
|
can_float = true
|
|
$OnFootPhysics.can_glide = can_glide
|
|
$OnFootPhysics.can_float = can_float
|
|
|
|
|
|
|