var _camera_input_direction := Vector2.ZERO
enum {CAMERA_MOUSE_INPUT, CAMERA_JOYSTICK_INPUT}
var _camera_input_direction := Vector2.ZERO
enum {CAMERA_MOUSE_INPUT, CAMERA_JOYSTICK_INPUT}
_debug.draw.add_vector(self, "_last_movement_direction", 1, 1, Color(1,0,0,1))
_debug.stats.add_property(self, "velocity", "length")
_debug.stats.add_property(self, "_idle_time", "round")
_debug.draw.add_vector(self, "_last_movement_direction", 1, 1, Color(1,0,0,1))
_debug.stats.add_property(self, "velocity", "length")
_debug.stats.add_property(self, "_idle_time", "round")
# if we're not stuck, then it's okay to set the velocity
_floor_normal = get_floor_normal()
# if we're not stuck, then it's okay to set the velocity
_floor_normal = get_floor_normal()
- var ground_angle := move_direction.angle_to(_floor_normal * Vector3(1, 0, 1))
- #print(str(ground_angle))
- velocity = velocity.move_toward(move_direction * (_player_speed + ground_angle), acceleration * delta)
+ _ground_slope_input = (PI / 2) - velocity.angle_to(_floor_normal)
+ velocity = velocity.move_toward(
+ move_direction * (_player_speed + _ground_slope_input * _player_speed),
+ acceleration * delta
+ )
var movement_speed := Vector3(velocity.x, 0, velocity.z).length()
# also, if we're moving, we're not idle
if move_direction.length() < 0.2:
if velocity == Vector3.ZERO:
_idle_time += delta
var movement_speed := Vector3(velocity.x, 0, velocity.z).length()
# also, if we're moving, we're not idle
if move_direction.length() < 0.2:
if velocity == Vector3.ZERO:
_idle_time += delta
# if camera is unlocked, rotate whole skin to face movement direction
var skin_target_angle := Vector3.BACK.signed_angle_to(_last_movement_direction, Vector3.UP)
# if camera is unlocked, rotate whole skin to face movement direction
var skin_target_angle := Vector3.BACK.signed_angle_to(_last_movement_direction, Vector3.UP)
_dust.emitting = velocity.length() > (0.75 * charge_speed) and is_on_floor()
_dust.amount_ratio = velocity.length()
else:
_skin.set_falling()
velocity += get_gravity() * air_speed * delta
_dust.emitting = velocity.length() > (0.75 * charge_speed) and is_on_floor()
_dust.amount_ratio = velocity.length()
else:
_skin.set_falling()
velocity += get_gravity() * air_speed * delta
# handle collisions
for i in get_slide_collision_count():
var c := get_slide_collision(i)
if c.get_collider() is RigidBody3D:
var col: RigidBody3D = c.get_collider()
# handle collisions
for i in get_slide_collision_count():
var c := get_slide_collision(i)
if c.get_collider() is RigidBody3D:
var col: RigidBody3D = c.get_collider()