when the host try to move it works perfectly fine, but on the client, the client player does not move
// Input system callback for movement
public void OnMovement(InputAction.CallbackContext value)
{
if (!IsOwner) return;
// Read and normalize 2D movement input
model.Movement2D = value.ReadValue<Vector2>();
model.Movement2D.Normalize();
// Set movement direction in the player's local space
model.Direction = new Vector3(model.Movement2D.x, 0, model.Movement2D.y);
model.Direction.Normalize();
// Apply the movement
controller.ApplyMovement();
}
void FixedUpdate()
{
if (!IsOwner) return;
// Apply gravity and movement in fixed intervals
ApplyGravity();
ApplyMovement();
}
// Apply player movement based on input
public void ApplyMovement()
{
ApplyMovementServerRpc();
}
[ServerRpc(RequireOwnership =false)]
private void ApplyMovementServerRpc()
{
model.IsWalking = model.Direction.x != 0 || model.Direction.z != 0;
float currentSpeed = model.Speed * (model.IsRunning && !model.IsCrouching ? model.SpeedWhileRunningMultiplier : model.IsCrouching ? model.SpeedWhileCrouchingMultiplier : 1);
Vector3 currentDirection = model.Direction;
// If stamina consumption is required, handle it
if (model.ShouldConsumeStamina)
{
HandleStaminaConsumption(currentSpeed);
}
// Rotate player based on camera angle if required
RotatePlayerByCameraAngle(ref currentDirection);
Debug.Log("mova desgraça");
model.Controller.Move(currentDirection * currentSpeed * Time.deltaTime);
}