Hello. I want to rotate and schoot a bullet on mouse position. Thats my script so far:
if (Input.GetButtonDown("Fire1"))
{
clickPos = -Vector3.one;
Vector3 punktA = new Vector3(1, 2, 0);
Vector3 punktB = new Vector3(2, 1, 0);
Vector3 punktC = new Vector3(3, 3, 0);
Plane plane = new Plane(punktA, punktB, punktC);
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
float DistanceToPlane;
if (plane.Raycast(ray, out DistanceToPlane))
{
clickPos = ray.GetPoint(DistanceToPlane);
}
Vector3 finalClickPos = new Vector3(clickPos.x, clickPos.y, 1);
Instantiate(bullet, transform.position, Quaternion.LookRotation (finalClickPos));
}
The problem is that this script rotates bullet on opposite direction (when i click upper left it rotates towards upper right). How can i fix it? thanks