Exemple #1
0
    /**
     * Base function for VFX
     * name: the name of the effect in resources/effects
     * position: where it spawns
     * delay: how long until it plays
     * emitter: name of the other effect when it dies
     */
    public GameObject PlayEffect(string name, Vector3 position, float delay, string emitter, float duration)
    {
        GameObject inta    = Resources.Load <GameObject>("Effects/" + name);
        GameObject effect  = Instantiate(inta, position, inta.transform.rotation);
        Transform  tEffect = effect.transform;
        VFXScript  vfx     = effect.GetComponent <VFXScript>();

        if (vfx != null && delay > 0)
        {
            vfx.delay = delay;
        }
        if (vfx != null && duration != 0)
        {
            vfx.duration = duration;
        }

        GameObject emit = Resources.Load <GameObject>("Effects/" + emitter);

        if (emit != null)
        {
            vfx.SetEmitter(emit);
        }

        return(effect);
    }
Exemple #2
0
    /**
     * Base function for VFX
     * name: the name of the effect in resources/effects
     * position: where it spawns
     * delay: how long until it plays
     * emitter: name of the other effect when it dies
     */
    public void PlayEffect(string name, Vector3 position, float delay, string emitter)
    {
        GameObject effect = Instantiate(Resources.Load <GameObject>("Effects/" + name), position, Quaternion.identity);

        VFXScript vfx = effect.GetComponent <VFXScript>();

        if (vfx != null && delay > 0)
        {
            vfx.delay = delay;
        }

        GameObject emit = Resources.Load <GameObject>("Effects/" + emitter);

        if (emit != null)
        {
            vfx.SetEmitter(emit);
        }
    }