I have a script to fire bullets in a 2d top down space
using UnityEngine;
using System.Collections;
public class Shoot : MonoBehaviour {
public GameObject BulletClone;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)) {
}
Plane zeroPlane = new Plane( Vector3.up, Vector3.zero );
Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
float distance;
if( zeroPlane.Raycast( ray, out distance ) )
{
Vector3 outputPosition = ray.origin + ray.direction * distance;
Debug.Log( "Position: " + outputPosition );
//You can use this position to rotate the bullet like so
BulletClone.transform.LookAt( outputPosition );
}
}
}
but the bullet does not appere