I had a problem with AI Bot's aiming. To fix this in my project I modified method LookDirection in PunLookSource and changed the Raycast to use lookPosition instead of m_NetworkLookPosition.
Posting here, because this might be a bug?
Posting here, because this might be a bug?
Code:
public Vector3 LookDirection(Vector3 lookPosition, bool characterLookDirection, int layerMask, bool includeRecoil, bool includeMovementSpread)
{
var collisionLayerEnabled = m_CharacterLocomotion.CollisionLayerEnabled;
m_CharacterLocomotion.EnableColliderCollisionLayer(false);
// Cast a ray from the look source point in the forward direction. The look direction is then the vector from the look position to the hit point.
RaycastHit hit;
Vector3 direction;
// changed: if (Physics.Raycast(m_NetworkLookPosition, m_NetworkLookDirection, out hit, m_NetworkLookDirectionDistance, layerMask, QueryTriggerInteraction.Ignore))
if (Physics.Raycast(lookPosition, m_NetworkLookDirection, out hit, m_NetworkLookDirectionDistance, layerMask, QueryTriggerInteraction.Ignore)) {
direction = (hit.point - lookPosition).normalized;
} else {
direction = m_NetworkLookDirection;
}
m_CharacterLocomotion.EnableColliderCollisionLayer(collisionLayerEnabled);
return direction;
}