Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Add force once when object is created

$
0
0
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); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles