コード例 #1
0
    void Update()
    {
        if (IsDead())
        {
            if (scatterFractions)
            {
                float     volume = trans.localScale.x * trans.localScale.y * trans.localScale.z;
                int       num    = (int)(volume * 500.0f);
                Matrix4x4 mat    = trans.localToWorldMatrix;
                MPWorld.s_instances[0].AddOneTimeAction(() => {
                    MPSpawnParams sp           = new MPSpawnParams();
                    sp.velocity_random_diffuse = 3.0f;
                    sp.lifetime = 30.0f;
                    MPAPI.mpScatterParticlesBoxTransform(MPWorld.s_instances[0].GetContext(), ref mat, num, ref sp);
                });
            }
            Destroy(gameObject);
        }
        if (Mathf.Abs(trans.position.x) > 30.0f ||
            Mathf.Abs(trans.position.z) > 30.0f)
        {
            Destroy(gameObject);
        }


        if (rigid)
        {
            Vector3 vel = rigid.velocity;
            vel.x         -= accel;
            vel.y          = 0.0f;
            rigid.velocity = vel;

            Vector3 pos = rigid.transform.position;
            pos.y *= 0.95f;
            rigid.transform.position = pos;

            float speed = rigid.velocity.magnitude;
            rigid.velocity = rigid.velocity.normalized * (Mathf.Min(speed, maxSpeed) * deccel);

            rigid.angularVelocity = rigid.angularVelocity * 0.98f;
        }
    }
コード例 #2
0
    void Update()
    {
        if(IsDead()) {
            if(scatterFractions) {
                float volume = trans.localScale.x * trans.localScale.y * trans.localScale.z;
                int num = (int)(volume * 500.0f);
                Matrix4x4 mat = trans.localToWorldMatrix;
                MPWorld.s_instances[0].AddOneTimeAction(() => {
                    MPSpawnParams sp = new MPSpawnParams();
                    sp.velocity_random_diffuse = 3.0f;
                    sp.lifetime = 30.0f;
                    MPAPI.mpScatterParticlesBoxTransform(MPWorld.s_instances[0].GetContext(), ref mat, num, ref sp);
                });
            }
            Destroy (gameObject);
        }
        if(Mathf.Abs (trans.position.x)>30.0f ||
           Mathf.Abs (trans.position.z)>30.0f )
        {
            Destroy (gameObject);
        }

        if(rigid) {
            Vector3 vel = rigid.velocity;
            vel.x -= accel;
            vel.y = 0.0f;
            rigid.velocity = vel;

            Vector3 pos = rigid.transform.position;
            pos.y *= 0.95f;
            rigid.transform.position = pos;

            float speed = rigid.velocity.magnitude;
            rigid.velocity = rigid.velocity.normalized * (Mathf.Min (speed, maxSpeed) * deccel);

            rigid.angularVelocity = rigid.angularVelocity * 0.98f;
        }
    }
コード例 #3
0
ファイル: MP.cs プロジェクト: Pheema/UnitySandBox
 [DllImport("MassParticle")] public static extern void mpScatterParticlesBoxTransform(int context, ref Matrix4x4 trans, int num, ref MPSpawnParams sp);
コード例 #4
0
ファイル: MP.cs プロジェクト: Pheema/UnitySandBox
 [DllImport("MassParticle")] public static extern void mpScatterParticlesBox(int context, ref Vector3 center, ref Vector3 size, int num, ref MPSpawnParams sp);
コード例 #5
0
ファイル: MP.cs プロジェクト: Pheema/UnitySandBox
 [DllImport("MassParticle")] public static extern void mpScatterParticlesSphere(int context, ref Vector3 center, float radius, int num, ref MPSpawnParams sp);
コード例 #6
0
ファイル: MP.cs プロジェクト: stlck/FractalTest
 public static extern void mpScatterParticlesSphereTransform(int context, ref Matrix4x4 trans, int num, ref MPSpawnParams sp);
コード例 #7
0
ファイル: MP.cs プロジェクト: stlck/FractalTest
 public static extern void mpScatterParticlesSphere(int context, ref Vector3 center, float radius, int num, ref MPSpawnParams sp);
コード例 #8
0
ファイル: MP.cs プロジェクト: stlck/FractalTest
 public static extern void mpScatterParticlesBox(int context, ref Vector3 center, ref Vector3 size, int num, ref MPSpawnParams sp);