Jump to content

Adding a stock particle effect [Solved]


Recommended Posts

Anyone have an easy way to add a stock particle effect to a transform?  Turn it off and on?

Thanks.

 

*edit*

Here's what I have that's not working:

                            float effectStrength = Mathf.Min((float)P, 1) * EffectThreshold;
                            effects = GetEffect();                            
                            var te = effects.Trail.emission;
                            effects.Trail.transform.position = this.part.FindModelTransform("exhaustTransform").position;
                            if (effectStrength > 0)
                            {
                                te.enabled = true;
                            }
                            else
                            {
                                te.enabled = false;
                            }
                            FASLog.Writelog("E " + effects.Trail.isEmitting);

with GetEffect() being

        public ValveEffect GetEffect()
        {
            GameObject effect = (GameObject)GameObject.Instantiate(Resources.Load("Effects/fx_gasBurst_white"));    
            ValveEffect vFx = new ValveEffect(effect);
            var tspeed = vFx.Trail.main.simulationSpeed;
            tspeed = 5;
            return vFx;
        }

No errors are produced anywhere, however, when examine the log I write to, isEmitting is false.

 

*edit* solved

Thot I had autoplay set to true.  Guess not.  I did this and it worked:

                            if (effectStrength > 0)
                                {
                                    te.enabled = true;
                                effects.Trail.Play(true);
                                }
                                else
                                {
                                    te.enabled = false;
                                effects.Trail.Play(false);
                            }

 

Edited by Fengist
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...