promiscuity/scenes/player.gd
2025-10-12 21:10:24 -05:00

17 lines
686 B
GDScript

extends RigidBody3D
# Initially I used a CharacterBody3D, however, I wanted the player to bounce off
# other objects in the environment and that would have required manual handling
# of collisions. So that's why we're using a RigidBody3D instead.
const ACCELLERATION = 5.0
func _integrate_forces(state):
var input_dir = Vector3.ZERO
input_dir.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_dir.z = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_dir = input_dir.normalized()
linear_velocity.x += input_dir.x * (ACCELLERATION * state.step)
linear_velocity.z += input_dir.z * (ACCELLERATION * state.step)