I’m using Transform.LookAt and the mouse position to rotate the character and shoot from it’s forward vector. However, the projectiles are off just a little depending where my cursor is. In certain spots they lineup and others they don’t.
The spawnpoint for the projectiles is a child object of the player. All the child objects’ rotations are exactly the same (0,0,0). The parent object is perpendicular to the terrain.
The forward vector of the spawn point and all the other objects line up perfectly to the projectiles, so I don’t think it’s a problem with the way the projectiles are spawning. Any suggestions?
RaycastHit hit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 newVector3;
if (Physics.Raycast(ray, out hit))
{
newVector3 = new Vector3(hit.point.x, transform.position.y, hit.point.z);
player.transform.LookAt(newVector3);
}