using UnityEngine;
using System.Collections;
public class Fire : MonoBehaviour {
public GameObject whiteCell;
public string fireButton = "Fire1";
public float shotPower = 1f;
public int ammo = 20;
// Use this for initialization
void Start () {
Instantiate (whiteCell, new Vector3(transform.position.x,-2.5f, 0), Quaternion.identity);
}
// Update is called once per frame
void Update () {
//while (ammo > 0){
//if (Input.GetButtonDown(fireButton)){
// Debug.Log("Hello");
// //ammo--;
//}
//whiteCell.transform.position += new Vector3(0, 0.1f, 0);
whiteCell.rigidbody.AddForce(transform.up * shotPower);
//}
}
}
I’m trying to shoot a “bullet” that will go directly upwards on the y-axis.
Unfortunately this is not working and I cannot get my head round why this is the case
I tried using the transform.position method and the rigidbody.AddForce method but both are not giving me results.
I’m sure there is something wrong with my code but I can’t find what exactly is wrong. Any insight will be greatly appreciated. Thanks ![]()