x


How to control World Particle Collider through script

Is there a way to add a world particle collider to a particle system through script. AddComponent(???);

If there's not a way to add it at runtime is there a way to enable/disable it?

more ▼

asked Apr 04 '11 at 12:21 AM

madeFromCode gravatar image

madeFromCode
31 2 2 6

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

1 answer: sort voted first

Add it to the actual particle effect, then you can enable/disable it...

Use get component

http://unity3d.com/support/documentation/ScriptReference/GameObject.html

To get the component, and just .enable = false/true on which you want..

Should work =). Good luck!

Code:

function Update () {
    if(Input.GetKeyDown("w")){
        var test = gameObject.GetComponent("WorldParticleCollider");
        print(test);
    }
}
more ▼

answered Apr 04 '11 at 12:39 AM

Justin Warner gravatar image

Justin Warner
6.5k 20 28 66

Preferably I'd like to create it in script with addComponent but I went ahead and added it to the prefab to try and control it that way. I can't seem to find out how to enable/disable it though. If I try to getComponent(Collider) it says there's not a collider attached. There's not an option, that I can find, for getting a WorldParticleCollider. Do you know the correct syntax for this?

Apr 04 '11 at 09:15 PM madeFromCode

Edited and it works... So, that test is a gameobject, so now you can do .enable = false/true...

Apr 04 '11 at 10:33 PM Justin Warner

Great! Thank you.

Apr 08 '11 at 10:19 PM madeFromCode

gameObject.GetComponent("WorldParticleCollider") It doesn't work at all.

Jun 12 '11 at 01:54 PM Yanger_xy
(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:

x2514
x929
x420
x389
x144

asked: Apr 04 '11 at 12:21 AM

Seen: 2829 times

Last Updated: Jun 12 '11 at 01:54 PM