Added acceleration and inertia
This commit is contained in:
@@ -40,6 +40,8 @@ var walk = 12
|
||||
var run = 24
|
||||
var jump = 16
|
||||
var gravity = 9.8
|
||||
var acceleration = 2.5
|
||||
var inertia = 20
|
||||
|
||||
var game_settings
|
||||
var client_settings
|
||||
@@ -203,12 +205,12 @@ func _physics_process(delta):
|
||||
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
||||
if direction:
|
||||
velocity.x = direction.x * speed
|
||||
velocity.z = direction.z * speed
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * acceleration)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * acceleration)
|
||||
else:
|
||||
if is_on_floor():
|
||||
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta * 20)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta * 20)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta * inertia)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta * inertia)
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta)
|
||||
@@ -252,6 +254,8 @@ func set_game_settings(s):
|
||||
walk = game_settings["moving"]["walk"]
|
||||
run = game_settings["moving"]["run"]
|
||||
jump = game_settings["moving"]["jump"]
|
||||
acceleration = game_settings["moving"]["acceleration"]
|
||||
inertia = game_settings["moving"]["inertia"]
|
||||
change_weapon(properties["current_weapon"]["number"])
|
||||
|
||||
@rpc ("authority", "call_remote", "reliable")
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
"walk": 12,
|
||||
"run": 24,
|
||||
"gravity": 9.8,
|
||||
"jump": 12
|
||||
"jump": 12,
|
||||
"acceleration": 2.5,
|
||||
"inertia": 20
|
||||
},
|
||||
"weapons": {
|
||||
"knife": {
|
||||
|
||||
Reference in New Issue
Block a user