public override void Emit(BulletEmitParam emitParam, Transform emitter)
        {
            var bulletComponent = Instantiate(bullet).AddComponent <GameObjectBullet>();
            var absEmitParam    = emitParam.RelativeTo(emitter);

            bulletComponent.Init(absEmitParam.position, absEmitParam.velocity, absEmitParam.color, absEmitParam.size);
            if (enableLifetime)
            {
                bulletComponent.EnableLifeTime(bulletLifeTime);
            }

            PlayEmissionEffect(emitParam, emitter);
        }
Exemple #2
0
        public override void Emit(BulletEmitParam relative, Transform emitter)
        {
            ParticleSystem.EmitParams ToEmitParams(in BulletEmitParam bulletEmitParam)
            {
                var result = new ParticleSystem.EmitParams();

                result.position = bulletEmitParam.position;
                result.velocity = bulletEmitParam.velocity;
                if (psr.renderMode == ParticleSystemRenderMode.Mesh)
                {
                    var startRotation3D = psm.startRotation3D
                                                ? new Vector3(
                        psm.startRotationX.Evaluate(ps.time) * psm.startRotationXMultiplier,
                        psm.startRotationY.Evaluate(ps.time) * psm.startRotationYMultiplier,
                        psm.startRotationZ.Evaluate(ps.time) * psm.startRotationZMultiplier)
                                                : new Vector3(0, 0, psm.startRotation.Evaluate(ps.time) * psm.startRotationMultiplier);
                    result.rotation3D =
                        (Quaternion.LookRotation(result.velocity == Vector3.zero ? Vector3.forward : result.velocity) *
                         Quaternion.Euler(startRotation3D)).eulerAngles;
                }
                if (!bulletEmitParam.DefaultColor)
                {
                    result.startColor = bulletEmitParam.color;
                }
                if (!bulletEmitParam.DefaultSize)
                {
                    result.startSize3D = bulletEmitParam.size;
                }

                return(result);
            }

            ps.Emit(
                psm.simulationSpace == ParticleSystemSimulationSpace.World
                                        ? ToEmitParams(relative.RelativeTo(emitter))
                                        : ToEmitParams(relative), 1);

            PlayEmissionEffect(relative, emitter);
        }