- Home /
 
 
               Question by 
               MaxTheGamer · Apr 20, 2016 at 01:37 PM · 
                instantiateshootingmissilejet  
              
 
              Rockets Shooting up, negative number doesnt solve it
Trying to fire missiles from a jet but the missiles travel to the top of the map Here is the code: using UnityEngine; using System.Collections;
 public class RocketScript : MonoBehaviour
 {
 
     public Rigidbody rocketPrefab;
     public Transform rocketLauncher1;
     public Transform rocketLauncher2;
     public Transform rocketLauncher3;
     public Transform rocketLauncher4;
     public float launchSpeed = 1;
     public Transform target;
 
     // Use this for initialization
     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         if (Input.GetButtonDown("Fire1"))
         {
             Rigidbody rocketInstance1;
             rocketInstance1 = Instantiate(rocketPrefab, rocketLauncher1.position, rocketPrefab.rotation) as Rigidbody;
             rocketInstance1.AddForce(transform.forward * -launchSpeed);
         }
     }
 }
 
              
               Comment
              
 
               
              Answer by nopogo · Apr 20, 2016 at 02:51 PM
maybe the rotation makes transform.forward an upwards vector3? Try using quaternian.identity instead of prefab.rotation.
But actually i tried rotating it and it doesnt work properly
Your answer