- Home /
Want to shoot to make an explosion
Hey this is simple and I am confused when I want to shoot I want an explosion coming out of the barrel. "Spawnpoint" actually. Here is my SHOOT script
var projectile : Rigidbody; var speed = 10;
function Update () {
if (Input.GetButtonDown("Fire1")) {
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward * speed);
}
}
Answer by FLASHDENMARK · Jan 12, 2011 at 12:08 PM
You just Instantiate a particle emitter. Like so:
var explosion : Transform;
function Update () { if(Input.GetButtonDown("Fire1"))
{ Instantiate(explosion,gameObject.Find("Spawnpoint").transform.position,Quaternion.identity); } }
Answer by kyle · Aug 21, 2010 at 12:16 AM
Okay here is what you can do this:
var projectile : Transform;
var speed = (whatever you want);
var explosion : Transform;
function Update () {
if (Input.GetButtonDown("Fire1"))
{
var clone = Instantiate(projectile, transform.Find("Spawnpoint").transform.position, Quaternion.identity);
var Exp = Instantiate(explosion, transform.Find("Spawnpoint").transform.position, Quaternion.identity);
clone.rigidbody.Addforce(transform.forward * speed); } }
Your answer
Follow this Question
Related Questions
First person shooter shoot Function 3 Answers
I want to be able to make a good shoot script that actually works. 0 Answers
Clones of enemies will not shoot 0 Answers
eating candy, spitting it out. 1 Answer
Instanciate Object Problem for Shooting 2 Answers