I used this script (It uses Mirror)
And I get this result.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerScript : NetworkBehaviour
{
public float speed = 10f;
public Rigidbody rb;
private bool onGround = true;
private float mouseX;
private float mouseY;
private float moveX;
private float moveZ;
public Animator anim;
public Transform head;
private void Start()
{
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
if (isLocalPlayer){
Cursor.lockState = CursorLockMode.Locked;
}
}
// Update is called once per frame
void FixedUpdate()
{
if (isLocalPlayer){
mouseX += Input.GetAxis("Mouse X") * Time.deltaTime * 180;
mouseY += Input.GetAxis("Mouse Y") * Time.deltaTime * -180;
mouseY = Mathf.Clamp(mouseY, -90, 90);
moveX = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
moveZ = Input.GetAxis("Vertical") * Time.deltaTime * speed;
anim.SetFloat("Vertical", Mathf.Abs(Input.GetAxis("Vertical")));
transform.localRotation = Quaternion.Euler(0,mouseX,0);
transform.Translate(moveX,0,moveZ);
head.localRotation = Quaternion.Euler(mouseY, 0, 0);
if(Input.GetButtonDown("Jump") && onGround)
{
rb.AddForce(new Vector3(0,40,0), ForceMode.Impulse);
}
anim.SetBool("Falls", onGround);
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "Floor")
{
onGround = true;
}
}
private void OnCollisionExit (Collision collision)
{
onGround = false;
}
}
Here’s the Components and its settings: