This commit is contained in:
dise 2024-02-27 11:53:14 +03:00
commit 46b3100cde
1 changed files with 12 additions and 8 deletions

View File

@ -202,8 +202,16 @@ func _physics_process(delta):
var input_dir = Input.get_vector("left", "right", "forward", "backward")
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if not is_on_floor():
velocity.y -= 4 * gravity * delta
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
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)
else:
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta)
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta)
if is_on_floor():
if Input.is_action_just_pressed("jump"):
velocity.y = jump
@ -211,16 +219,12 @@ func _physics_process(delta):
speed = run
else:
speed = walk
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 4)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 4)
else:
velocity.y -= 4 * gravity * delta
velocity.x = lerp(velocity.x, direction.x * speed, delta)
velocity.z = lerp(velocity.z, direction.z * speed, delta)
move_and_slide()
if (!multiplayer.is_server()):
if (!properties["offline_mode"]): Networking.sync_client.rpc_id(1, multiplayer.get_unique_id(), $".".position, {"y": head.rotation.y, "x": camera.rotation.x})
#print("I am " + $"..".name +", belonging of " + str(multiplayer.get_unique_id()) + ", with internal ID: " + str(properties["internal_id"]))