so im making a 2d space shooter type game that player looks where the mouse is at. The problem is player has cannons that shoots lazers but idk how to make lazers go to the way its faacing i tried Vector3.forward but it was moving it in the z axis. Like if my player is looking down i want the lazer to go down if the player is looking at northwest i want my bullet to go northwest if my players rotation is x = 90 i want my lazer rotation x = 90
can someone help?
and here is the laser code
public class Laser : MonoBehaviour
{
[SerializeField]
private float speed = 10f;
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self);
if(transform.position.y > 20 || transform.position.y < -20 || transform.position.x > 20 || transform.position.x < -20)
{
if (transform.parent != null)
Destroy(transform.parent.gameObject);
Destroy(gameObject);
}
}