Export player speeds to inspector and decrease run speed

This commit is contained in:
Jarrod Doyle 2024-02-23 11:35:50 +00:00
parent 4efbfe667e
commit 3295e03343
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 19 additions and 14 deletions

View File

@ -10,13 +10,14 @@ radius = 0.25
[node name="Player" type="StaticBody3D" node_paths=PackedStringArray("head", "body", "camera", "collision_shape")]
script = ExtResource("1_i6r2s")
max_speed = 6
slope_limit = 40.0
step_height = 0.3
snap_to_ground_distance = 0.3
head = NodePath("Body/Head")
body = NodePath("Body")
camera = NodePath("Body/Head/Smoother/Camera3D")
collision_shape = NodePath("MoveCollider")
slope_limit = 40.0
step_height = 0.3
snap_to_ground_distance = 0.3
[node name="MoveCollider" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0)

View File

@ -1,12 +1,9 @@
extends PhysicsBody3D
@export var head : Node3D
@export var body : Node3D
@export var camera : DampenedCamera3D
## A reference to the collision shape this physics body is using
## (It's just a bit easier rather than aquiring the reference via code)
@export var collision_shape : CollisionShape3D
@export var jump_speed := 4.5
@export var max_speed := 8
@export var slow_speed := 2
@export var mouse_sensitivity := 0.002 # radians/pixel
## The character will be blocked from moving up slopes steeper than this angle
## The character will be not be flagged as 'grounded' when stood on slopes steeper than this angle
@ -19,6 +16,14 @@ extends PhysicsBody3D
## This keeps the character on steps, slopes, and helps keep behaviour consistent
@export var snap_to_ground_distance := 0.2
@export_group("Connector Nodes")
@export var head : Node3D
@export var body : Node3D
@export var camera : DampenedCamera3D
## A reference to the collision shape this physics body is using
## (It's just a bit easier rather than aquiring the reference via code)
@export var collision_shape : CollisionShape3D
@export_group("Advanced")
## Stop movement under this distance, but only if the movement touches at least 2 steep slopes
@ -55,13 +60,12 @@ extends PhysicsBody3D
## accurate. 4 is a decent number for low poly terrain!
@export var max_iteration_count := 4
var jump_speed := 4.5
var jump_pressed := false
var gravity := 9.8
var max_speed := 8
var slow_speed := 2
var mouse_sensitivity := 0.002 # radians/pixel
var _velocity : Vector3 = Vector3()
var at_max_speed : bool = true