Cinemachine integration not aiming crosshairs

What Cinemachine camera type are you using? Does CinemachineViewType.LookDirection return the correct direction? It uses CinemachineBrain.CurrentCameraState to determine the camera rotation.
 
What Cinemachine camera type are you using? Does CinemachineViewType.LookDirection return the correct direction? It uses CinemachineBrain.CurrentCameraState to determine the camera rotation.
I use free look for my camera,and i set Player's transform to Follow and and Look field.The look direction is not correct,it's always lower than the corsshair position
 
this is the same frame of game view and scene view
 

Attachments

  • gameview.png
    gameview.png
    463.8 KB · Views: 7
  • sceneview.png
    sceneview.png
    328.9 KB · Views: 6
If you draw a debug ray within the LookDirection method does it look correct?
 
If you draw a debug ray within the LookDirection method does it look correct?
no,the debug ray is not aiming the crosshairs position.I notice CinemachineViewType use orientation to caculate the LookDirection,while ThirdPerson use ray cast.Could this be the cause of the incorrect LookDirection
 
I just placed a cube in front of the crosshairs and my results are below. The green line is the debug ray from the CharacterIK component and the while line originating from the top of the character is from the CrosshairsMonitor:

1636372192318.png

1636372220941.png

You could try adjusting the Look Direction Distance on the ViewType - this is what determines how long the lines extend.
 
I just placed a cube in front of the crosshairs and my results are below. The green line is the debug ray from the CharacterIK component and the while line originating from the top of the character is from the CrosshairsMonitor:

View attachment 7592

View attachment 7593

You could try adjusting the Look Direction Distance on the ViewType - this is what determines how long the lines extend.
Thanks for the example,my results are the same.In the ShootableWeapon.cs script,when invoke ProjectileFire method,the projectile use the camera's direction(the green line),and start from the fire point,so it's always lower than the target.Is there a way to fix this?
 
There isn't a built in way, but until I add it as a new feature you could subclass the View Type and return a slight offset to the LookDirection method.
 
Hi, have you found a way to fix that? I have the same problem, can't move the crosshair, the green line does not follow the crosshairs
Use ray cast

var ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0));
var hits = Physics.SphereCastAll(ray, 0.25f, 50, m_ImpactLayers, QueryTriggerInteraction.Ignore);
if (hits != null && hits.Length > 0)
{
var hitObject = false;
foreach (var hit in hits.OrderBy(i => i.distance))
{
if (hit.transform.IsChildOf(m_Character.transform)) continue;
var dir = hit.point - firePoint;
if (Vector3.Dot(dir, Camera.main.transform.forward) < 0) continue;
direction = dir;
hitObject = true;
break;
}
if(!hitObject)
direction = Camera.main.transform.forward * 50 + Camera.main.transform.position - firePoint;
}
else
{
direction = Camera.main.transform.forward * 50 + Camera.main.transform.position - firePoint;
}
 
Use ray cast

var ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0));
var hits = Physics.SphereCastAll(ray, 0.25f, 50, m_ImpactLayers, QueryTriggerInteraction.Ignore);
if (hits != null && hits.Length > 0)
{
var hitObject = false;
foreach (var hit in hits.OrderBy(i => i.distance))
{
if (hit.transform.IsChildOf(m_Character.transform)) continue;
var dir = hit.point - firePoint;
if (Vector3.Dot(dir, Camera.main.transform.forward) < 0) continue;
direction = dir;
hitObject = true;
break;
}
if(!hitObject)
direction = Camera.main.transform.forward * 50 + Camera.main.transform.position - firePoint;
}
else
{
direction = Camera.main.transform.forward * 50 + Camera.main.transform.position - firePoint;
}
Thanks for answering. Where did you do that? Did you subclass the cinemachine viewtype? Did you do that in the shootableWeapon class?
 
Top