I’m trying to make a 2D game with a laser that the player can shoot that reflects off of mirrors, but I’m kinda new to Unity.
It all works, except that I can’t get the player to fire the laser at the mouse position. I have no trouble getting the mouse position using:
Vector3 screenPos = Input.mousePosition;
screenPos.z = 0;
Vector3 worldPos = Camera.mainCamera.ScreenToWorldPoint(screenPos);
But simply using the LookAt() function like all the tutorials show will not work for me. Because of the equation I’m using to calculate reflection, I need a single value out of 360 to define the direction the laser is moving in. I’m going with the EulerAngle.z value. So basically, what I need is to get the direction from the player’s x and y position to the mouse position in a single value out of 360. Then I can just set the laser’s eulerAngles.z rotation to that.
Any help of any kind would be appreciated, especially in C# as that is the language I’m using.