So I made a script that moves the player and a script that move a camera on a different gameobject but just one player input work (the one that I last add). Each script works with send message. So one has OnMove() and the other has OnLook(). And I notice that on Mac the two Player Input work but on Windows don’t. I don’t know If this a bug or this is just me.
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f;
public float lookSensitivity = 2f;
private Vector2 moveInput;
private Vector2 lookInput;
private CharacterController characterController;
private Transform playerCamera;
private void Awake()
{
characterController = GetComponent<CharacterController>();
playerCamera = Camera.main.transform;
}
public void OnMove(InputAction.CallbackContext context)
{
// Read the movement input (WASD / Left Stick)
moveInput = context.ReadValue<Vector2>();
Debug.Log("Move Input: " + moveInput);
}
public void OnLook(InputAction.CallbackContext context)
{
// Read the look input (Mouse Delta / Right Stick)
lookInput = context.ReadValue<Vector2>();
Debug.Log("Look Input: " + lookInput);
}
private void Update()
{
// Handle player movement
Vector3 move = new Vector3(moveInput.x, 0, moveInput.y);
move = transform.TransformDirection(move); // Convert local to world space
characterController.Move(move * moveSpeed * Time.deltaTime);
// Handle camera look (rotation)
float lookX = lookInput.x * lookSensitivity;
float lookY = lookInput.y * lookSensitivity;
// Rotate the player horizontally
transform.Rotate(0, lookX, 0);
// Rotate the camera vertically
playerCamera.Rotate(-lookY, 0, 0);
}
}
This is not my question.