friction and sand pit
This commit is contained in:
parent
08712cf22c
commit
77ef1dee48
5 changed files with 81 additions and 35 deletions
|
@ -11,6 +11,8 @@ extends CharacterBody3D
|
|||
@export_group("Movement")
|
||||
@export var gravity: float
|
||||
@export var friction: float
|
||||
@export var friction_coef: float
|
||||
@export var friction_pow: float
|
||||
@export var stop_threshold: float
|
||||
|
||||
@export_group("Camera", "camera_")
|
||||
|
@ -101,13 +103,18 @@ func _apply_gravity(delta: float) -> void:
|
|||
|
||||
func _slow_to_stop(delta: float) -> void:
|
||||
if is_on_floor():
|
||||
var new_velocity = velocity
|
||||
new_velocity.y = 0.0
|
||||
var new_velocity = velocity * Vector3(1.0, 0.0, 1.0)
|
||||
|
||||
#new_velocity = lerp(new_velocity, Vector3.ZERO, friction_coef * delta)
|
||||
#new_velocity = lerp(
|
||||
#new_velocity, Vector3.ZERO,
|
||||
#power_scale * pow(friction_coef / new_velocity.length(), friction_pow * delta)
|
||||
#)
|
||||
new_velocity = new_velocity.move_toward(Vector3.ZERO, friction * delta)
|
||||
if new_velocity.length_squared() <= stop_threshold * stop_threshold:
|
||||
new_velocity = Vector3.ZERO
|
||||
new_velocity.y = velocity.y
|
||||
velocity = new_velocity
|
||||
velocity.x = new_velocity.x
|
||||
velocity.z = new_velocity.z
|
||||
|
||||
func _bounce_on_walls(delta: float = 0.0) -> void:
|
||||
var h_vel = (prev_velocity * Vector3(1.0, 0.0, 1.0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue