Hello guys,
I managed to get a simple shooting script working however when
I shoot it always shoots in a certain direction which is the top right.
Its supposed to shoot at my mouse. Here is the relavant code:
void Shoot(){
if (Input.GetMouseButtonDown (0)) {
target = Camera.main.WorldToScreenPoint (Input.mousePosition);
target.z = transform.position.z;
GameObject shotr = Instantiate (Resources.Load ("bullet"), transform.position, Quaternion.identity) as GameObject;
shotr.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (target.x, target.y));
// bullet.SendMessage ("gotot");
}