x


Particle system turns on when player gets close.

I need help with turning on a particle system when the player gets close to it. I also need it to turn off when the player is out of its radius. javascript is how I am writing the code. I currently don't have a script written yet.

more ▼

asked May 25 '12 at 04:59 AM

jose_gomez68 gravatar image

jose_gomez68
0 1 3 3

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

1 answer: sort voted first

You will be using distance in an if conditional or use an isTrigger collider to trigger the event.

On particle systems gameObjects script

if( (player.transform.position-transform.position) <= desiredDistance )
{
    //Start emission
}

or with the trigger (This trigger is on the particle systems gameObject)

function OnTriggerEnter(other:Collider)
{
    if(other.tag == "Player")
    {
        //Start emission
    }
}
function OnTriggerExit(other:Collider)
{
    //End emission
}
more ▼

answered May 25 '12 at 05:46 AM

hijinxbassist gravatar image

hijinxbassist
2k 23 31 38

The preferred method would be the latter using the trigger. It will be more efficient since the cpu will not need to continually calculate the distance between the particle system and the player. Let me know if you need help setting it up.

May 25 '12 at 05:48 AM hijinxbassist
(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:

x801
x318
x204
x72
x31

asked: May 25 '12 at 04:59 AM

Seen: 596 times

Last Updated: May 25 '12 at 06:14 AM