How can I spawn an object and add force onto it?
Thank you for your time!!!
How can I spawn an object and add force onto it?
Thank you for your time!!!
Just make a variable for example bullet and it has to be of type transform and then use this code inside your function. You also have to make a spawnpoint, were you want the bullet to appear.
var bulletPrefab : Transform;
var bullet = Instantiate(bulletPrefab,transform.Find("SpawnPointCannon").transform.position, Quaternion.identity);
// this applies a force to your bullet
bullet.rigidbody.AddForce(transform.forward * 1000);