x


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);


    }
}
more ▼

asked May 11 '10 at 12:31 AM

DTJ Productions gravatar image

DTJ Productions
57 19 20 25

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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);
    }
}
more ▼

answered Jan 12 '11 at 12:08 PM

OrangeLightning gravatar image

OrangeLightning
5.4k 47 57 113

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Aug 21 '10 at 12:16 AM

kyle gravatar image

kyle
58 6 6 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3569
x330
x163

asked: May 11 '10 at 12:31 AM

Seen: 1264 times

Last Updated: May 11 '10 at 12:31 AM