so in my game the player rotates to face the mouse but i want to make it so that when i click or something a bullet is created and it shoots towards that direction im facing heres my move.rotate script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Playermove : MonoBehaviour {
public float moveSpeed = 2;
// Update is called once per frame
void Update () {
if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
{
transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
}
if (Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f)
{
transform.Translate(new Vector3(0f, Input.GetAxisRaw("Vertical") * moveSpeed * Time.deltaTime, 0f));
}
facemouse();
}
void facemouse ()
{
Vector3 mousePos = Input.mousePosition;
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
Vector2 direction = new Vector2(
mousePos.x - transform.position.x,
mousePos.y - transform.position.y
);
transform.up = direction;
}
}