Hi guys i have a problem aiming in 3rd person with Cinemachine. Basically i’m trying to create a 3rd person shooter controller with two cinemachine, one for the normal movement and one for the aiming. The first works very good with a framing transposer in the body and a POV in the Aim, while for the second i can’t find good settings to adjust it. I tried to duplicate the first and mantain the same settings with a lower camera distance but the camera movement is not good at all. I also tried with 3rd person follow in the body, nothing in the aim and adjust it via script, but i can’t find a solution. I want the camera to rotate and look where the player is aiming. I’m using Control as videogame reference and trying to replicate it, so the player rotates by aiming on the x axis but stay put while aiming on the y axis. I specify that i’m using the new input system and the animation rigging, this is my script:
//Player rotation method
void PlayerRotation()
{
if (PlayerRifleAimingIdle.PlayerIsAiming)
{
transform.Rotate(new Vector3(0f, m_mouseDelta.x * m_aimSensivity, 0f));
}
if (IsMovementPressed && !PlayerRifleAimingIdle.PlayerIsAiming)
{
Quaternion targetRotation = Quaternion.LookRotation(m_moveDir);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.fixedDeltaTime * m_rotationSpeed);
}
}
//Player aiming method
void AimTarget()
{
if (PlayerRifleAimingIdle.PlayerIsAiming)
{
m_rig.weight = 1f;
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2f, m_mousePosition.y, 0f));
if (Physics.Raycast(ray, out RaycastHit hit))
{
m_aimTarget.position = hit.point;
m_crosshair.SetActive(true);
m_crosshairPos.anchoredPosition = new Vector2(m_crosshairPos.anchoredPosition.x, m_mousePosition.y);
}
}
else
{
m_crosshair.SetActive(false);
m_rig.weight = 0f;
}
}
This is a video of my project so you can better see what i want to achieve: