So i am trying to make the player shoot in the direction the mouse is pointing from my player. i have writen some code that gets me the angle. but i dont want the player to shoot at the mouse only straight up, left and right. like in the video below.
https://streamable.com/iy14yr
private void FixedUpdate()
{
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
difference.Normalize();
float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
Debug.Log(rotationZ);
}
the joystick im moving around is giving out values from -1 to 1 which seems easier but i dont know how i could make the screen cordinates into that. but let me know if you have a solution for that