- Home /
 
 
               Question by 
               The-Little-Guy · Jan 22, 2015 at 11:01 PM · 
                rigidbodyrigidbody2daddforceawake  
              
 
              Add force once when object is created
I thought that this would add force once as soon as the object was created, but what happens is that the object just falls to the ground. Am I not doing this right?
 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(Rigidbody2D))]
 public class Bullet : MonoBehaviour {
 
     public int damageAmount;
     public float speed;
     public float timeToLive = 0;
 
     // Use this for initialization
     void Awake () {
         rigidbody2D.AddForce(transform.forward * speed, ForceMode2D.Impulse);
         Destroy(gameObject, timeToLive);
     }
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by DanSuperGP · Jan 22, 2015 at 11:07 PM
Transform.forward is the Z axis.
Rigidbody2D's don't move on the Z axis.
Try transform.right instead.
It took me a few $$anonymous$$utes of staring at it to figure it out. I was sitting there going.... everything looks fine....
Your answer