Trying to have a mouse shoot the ball at the cursor in a top down 3d game (not 100% top down, closer to diagnal down).
There is a laser pointer on the player so you know where they are aiming, and they shoot along that laser pointer path.
This works initially:
Vector3 lookAt = camera1.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, (transform.position - camera1.transform.position).magnitude));
lookAt.y = this_laser_pointer.transform.position.y;
transform.LookAt(lookAt);
But when the player moves at all, they start looking up/down and the player angle is changed, which results in the aiming being off. The rotation constraints don’t seem to effect this. Is there a way to have lookAt result in only looking at that one axis to keep the player’s aim even?
This code corrects the player angle and aiming issues, but the player’s facing direction has a very hard time following the mouse cursor:
Vector3 lookAt = camera1.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, (transform.position - camera1.transform.position).magnitude));
lookAt.y = this_laser_pointer.transform.position.y;
motor.facingDirection = lookAt;
Thank you in advance.