So I’m trying to set up a system where I have “GunNodes” which spawn bullets and fire them in the direction that the nodes are facing. So far, I’ve been having some trouble.
BulletCode:
function Update () {
LifeTime += Time.deltaTime;
transform.position += Vector3.forward * BulletSpeed * Time.deltaTime;
if(LifeTime >= Range){
Destroy(gameObject);
}
GunCode:
function FireGuns (){
FiringCoolDown = true;
Instantiate(BulletObj, GunNode.position, GunNode.rotation);
Handheld.Vibrate ();
yield WaitForSeconds(FireRate);
FiringCoolDown = false;
}
Particularly, how can I spawn an object and cause it to move in the direction that another object is facing?