After Spending so much time I made this script, I am using the generated c# class for input action and it seem to fix all my issue with it, gonna leave it here, maybe it can help someone.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Temp : MonoBehaviour
{
[SerializeField] float lookSpeed = 5;
[SerializeField] float forceMagnitude = 10;
[SerializeField] float maxVelocity = 6;
PlayerInputAction playerInputAction;
Vector2 movementDirection;
Vector2 lookDirection;
Rigidbody rb;
private void Awake()
{
playerInputAction = new PlayerInputAction();
playerInputAction.Enable();
}
private void Update()
{
LookAtMouse();
}
private void FixedUpdate()
{
MovePlayer();
}
private void MovePlayer()
{
movementDirection = playerInputAction.Player.Move.ReadValue();
movementDirection.Normalize();
Vector3 movement = new Vector3(movementDirection.x, 0f, movementDirection.y);
rb.AddForce(movement * forceMagnitude, ForceMode.Force);
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);
}
private void LookAtMouse()
{
lookDirection = playerInputAction.Player.Look.ReadValue();
lookDirection.Normalize();
Vector3 direction = new Vector3(lookDirection.x, 0f, lookDirection.y);
if (direction != Vector3.zero)
{
Quaternion lookRotation = Quaternion.LookRotation(direction, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, lookSpeed * Time.deltaTime);
}
}
}