the easiest way is to use a Cinemachine. Use the Unity Package Manager (in the top menu: Window > Package Manager) to select Cinemachine for installation. also, Cinemachine supports a number of 2D-specific features, including orthographic rendering and 2D framing, where you can compose, track and follow objects.
In this solution if your player is facing in the opposite direction of world's forward axis the mouse Y input will invert, to fix that you can use player's up and right axis instead of world. Basically the code will look like transform.Rotate(playerTransform.right, mouseYInput, Space.World); transform.Rotate(playerTransform.up, mouseXInput, Space.World);
Thank you! I've been trying to implement object rotation in my first person game and I struggled to make the rotation relative to the player's orientation instead of just rotating the object around itself. This is exactly what I needed!
Can you please tell me that how can we rotate our camera in unity with fixed touch input field. So that we can give input from mobile
the easiest way is to use a Cinemachine. Use the Unity Package Manager (in the top menu: Window > Package Manager) to select Cinemachine for installation. also, Cinemachine supports a number of 2D-specific features, including orthographic rendering and 2D framing, where you can compose, track and follow objects.
In this solution if your player is facing in the opposite direction of world's forward axis the mouse Y input will invert, to fix that you can use player's up and right axis instead of world.
Basically the code will look like
transform.Rotate(playerTransform.right, mouseYInput, Space.World);
transform.Rotate(playerTransform.up, mouseXInput, Space.World);
Thanks for the information!
Thank you! I've been trying to implement object rotation in my first person game and I struggled to make the rotation relative to the player's orientation instead of just rotating the object around itself. This is exactly what I needed!