meat_madness_redux/godot/player/player.gd

44 lines
1.1 KiB
GDScript3
Raw Normal View History

2022-11-27 13:31:09 -07:00
extends Spatial
onready var active_physics_node: Spatial = $OnFootPhysics
2023-01-02 23:18:07 -07:00
export var can_glide: bool = false
2023-01-02 23:34:50 -07:00
export var can_float: bool = false
export var float_factor = 0.5
2023-01-02 23:18:07 -07:00
2022-12-27 13:24:35 -07:00
func _ready():
Util.player = self
2022-11-27 19:55:11 -07:00
func is_on_foot():
return active_physics_node == $OnFootPhysics
2022-11-27 13:31:09 -07:00
2022-12-05 09:46:58 -07:00
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
2022-11-27 13:31:09 -07:00
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
2022-12-27 13:24:35 -07:00
func objective_distance() -> float:
return $ObjectiveTracker.objective_distance
2023-01-02 23:18:07 -07:00
func _process(_delta):
$OnFootPhysics.can_glide = can_glide
2023-01-02 23:34:50 -07:00
$OnFootPhysics.can_float = can_float
$OnFootPhysics.float_factor = float_factor
2023-01-02 23:18:07 -07:00