Search Unity

Projectile clones not moving forward

Discussion in '2D' started by Burglebutt, Jul 28, 2014.

  1. Burglebutt

    Burglebutt

    Joined:
    Jul 24, 2014
    Posts:
    51
    Hello everybody, okay so I was following this tutorial to set up Instantiate in my 2d side scroller game that I am making...http://unity3d.com/learn/tutorials/modules/beginner/scripting/instantiate
    I feel like I must be making some stupid mistake. The clones of the projectile just stay in place where my character is at any given time... I have kinematic set to off and I tried changing the RocketPlace transform position to see if it was facing the wrong direction... totally stumped on this and not sure what to do... any insight? Thank you -Gene











    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class UsingInstantiate : MonoBehaviour
    5. {
    6.     public Rigidbody rocketPrefab;
    7.     public Transform barrelEnd;
    8.  
    9.  
    10.     void Update ()
    11.     {
    12.     if(Input.GetButtonDown("Fire1"))
    13.         {
    14.             Rigidbody rocketInstance;
    15.                 rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
    16.             rocketInstance.AddForce(barrelEnd.forward * 5000);
    17.  
    18.  
    19.     }
    20. }
    21. }
     
  2. Burglebutt

    Burglebutt

    Joined:
    Jul 24, 2014
    Posts:
    51
    Okay I figured out my mistake for anybody who might have the same issue... I had a rigid body on my rocket prefab and had kinematic checked... DOH!