- Home /
Question by
EytanTKing · Jun 01, 2011 at 05:37 PM ·
spawnaddforceshoot
How to spawn an object with an added force
How can I spawn an object and add force onto it?
Thank you for your time!!!
Comment
Answer by BarkShark · Jun 01, 2011 at 05:43 PM
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);
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
GetComponentInChildren(Renderer).active wont work? 2 Answers
Help with addforce 1 Answer
Spawning Error.. 0 Answers
Error in script to make a monster shoot against the player 1 Answer