Пример #1
0
    // Update is called once per frame
    void Update()
    {
        model.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        motionQueueManager.updateParam(model);
        eyeBlinkMotion.setParam(model);

        model.update();
        if (GameManager.Instance.isGameOver)
        {
            return;
        }
        if ((missCui.transform.position.x - transform.position.x) < 3)
        {
            GameManager.Instance.isGameOver = true;
            GameManager.Instance.isCatched  = true;
        }
        if (isDefeat)
        {
            transform.position = Vector3.Lerp(transform.position, initPos, 0.1f);
            Destroy(gameObject);
        }
        else
        {
            transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
        }
    }
Пример #2
0
    void OnPostRender()
    {
        Live2DModelUnity live2DModel = (Live2DModelUnity)_model.getLive2DModel();
        var w = live2DModel.getCanvasWidth();
        var h = live2DModel.getCanvasHeight();

        L2DModelMatrix matrix = new L2DModelMatrix(w, h);

        matrix.setWidth(_w);
        matrix.setCenterPosition(0.5f, 0.5f);
        matrix.setX(_x);
        matrix.setY(_y);

        Matrix4x4 m1 = Matrix4x4.identity;

        float[] m2 = matrix.getArray();
        for (int i = 0; i < 16; i++)
        {
            m1[i] = m2[i];
        }

        live2DModel.setMatrix(m1);

        //_model.Update();_model.Draw 中有调用
        UpdateMouth();
        live2DModel.update();
        _model.Draw(Live2dViewType);
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        live2DMode.setMatrix(transform.localToWorldMatrix * transformMar);
        motionManager.updateParam(live2DMode);

        Vector3 mousePos = Input.mousePosition;

        if (Input.GetMouseButton(0))
        {
            dragEff.Set(mousePos.x / Screen.width * 2 - 1, mousePos.y / Screen.height * 2 - 1);
        }

        if (Input.GetMouseButtonUp(0))
        {
            dragEff.Set(0, 0);
        }
        dragEff.update();
        if (dragEff.getX() != 0 && dragEff.getY() != 0)
        {
            live2DMode.setParamFloat("PARAM_ANGLE_X", dragEff.getX() * 30);
            live2DMode.setParamFloat("PARAM_ANGLE_Y", dragEff.getY() * 30);
            live2DMode.setParamFloat("PARAM_EYE_BALL_X", -dragEff.getX());
            live2DMode.setParamFloat("PARAM_EYE_BALL_Y", -dragEff.getY());
            live2DMode.setParamFloat("PARAM_BODY_ANGLE_X", 10 * dragEff.getX());
            live2DMode.setParamFloat("PARAM_BODY_ANGLE_Y", 10 * dragEff.getY());
        }
        live2DMode.update();
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        motionQueueManager.updateParam(live2DModel);
        eyeBlinkMotion.setParam(live2DModel);

        live2DModel.update();
        if (GameManager.Instance.gameOver)
        {
            return;
        }
        //判断当前Boss是否追赶上翠花
        if ((missCui.transform.position.x - transform.position.x) < 3)
        {
            GameManager.Instance.gameOver = true;
        }

        if (isDefeat)
        {
            transform.position = Vector3.Lerp(transform.position, initPos, 0.2f);
        }
        else
        {
            transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
        }
    }
Пример #5
0
    void Update()
    {
        live2dModel.setMatrix(transform.localToWorldMatrix * live2dCanvasPos);
        if (l2dMotionManager.isFinished())
        {
            StartMotion(0, 1);
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            StartMotion(14, 2);
        }
        l2dMotionManager.updateParam(live2dModel);

        Vector3 pos = Input.mousePosition;

        drag.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
        live2dModel.setParamFloat("PARAM_ANGLE_X", 30 * drag.getX());
        live2dModel.setParamFloat("PARAM_BODY_ANGLE_X", 10 * drag.getX());
        live2dModel.setParamFloat("PARAM_EYE_BALL_X", -drag.getX());
        live2dModel.setParamFloat("PARAM_EYE_BALL_Y", -drag.getY());
        drag.update();

        long time = UtSystem.getUserTimeMSec();

        physicHairSide.update(live2dModel, time);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            motionIndex = (motionIndex + 1 >= expressionMotions.Length ? 0 : motionIndex + 1);
            //expressionMotions[motionIndex].setLoop(true);
            motionQueueManager.startMotion(expressionMotions[motionIndex]);
        }
        motionQueueManager.updateParam(live2dModel);
        live2dModel.update();
    }
Пример #6
0
 /// <summary>
 /// カメラがシーンにレンダリング後に呼ばれる
 /// </summary>
 void OnRenderObject()
 {
     if (live2DModel == null)
     {
         return;
     }
     live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
     // アプリが終了していた場合
     if (!Application.isPlaying)
     {
         live2DModel.update();
         live2DModel.draw();
         return;
     }
     // 再生中のモーションからモデルパラメータを更新
     if (motionManager != null)
     {
         motionManager.updateParam(live2DModel);
     }
     // ポーズの設定
     if (pose != null)
     {
         pose.updateParam(live2DModel);
     }
     // 物理演算の設定
     if (physics != null)
     {
         physics.updateParam(live2DModel);
     }
     // 頂点の更新
     live2DModel.update();
     // モデルの描画
     live2DModel.draw();
 }
Пример #7
0
    void OnRenderObject()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            live2DModel.draw();
            return;
        }

        if (motionMgr.isFinished())
        {
            motionMgr.startMotion(motion);
        }

        motionMgr.updateParam(live2DModel);

        live2DModel.update();
        live2DModel.draw();
    }
Пример #8
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            //motionManager.updateParam (live2DModel);
            return;
        }

        /*
         * var pos = Input.mousePosition;
         * if (Input.GetMouseButtonDown(0))
         * {
         * //
         * }
         * else if (Input.GetMouseButton(0))
         * {
         * dragMgr.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
         * }
         * else if (Input.GetMouseButtonUp(0))
         * {
         * dragMgr.Set(0, 0);
         * }
         */


        dragMgr.update();
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        if (motionManager.isFinished())
        {
            StartCoroutine(FadeModel(0, 1));
        }
        live2DModel.update();
        motionManager.updateParam(live2DModel);
    }
Пример #9
0
 void Update()
 {
     live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvansPos);
     if (EyeFlag)
     {
         DragMove();
     }
     live2DModel.update();
 }
Пример #10
0
    private IEnumerator Routine_Main()
    {
        while (true)
        {
            while (true)
            {
                if (live2DModel == null)
                {
                    break;
                }
                live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

                if (!Application.isPlaying)
                {
                    live2DModel.update();
                    break;
                }

                if (motionMgr.isFinished() || main != _State)
                {
                    //歩き
                    if (_State == EnemyState.Walk)
                    {
                        motionMgr.startMotion(motions[0]);
                    }
                }

                if (main != _State)
                {
                    //噛みつき
                    if (_State == EnemyState.Attack)
                    {
                        motionMgr.startMotion(motions[1]);
                    }
                    //怯み
                    else if (_State == EnemyState.Stop)
                    {
                        motionMgr.startMotion(motions[2]);
                    }
                    //停止
                    if (_State == EnemyState.Wait)
                    {
                        motionMgr.startMotion(motions[3]);
                    }
                }

                main = _State;

                motionMgr.updateParam(live2DModel);
                live2DModel.update();
                live2DModel.draw();

                yield return(null);
            }
            yield return(null);
        }
    }
Пример #11
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        var pos = Input.mousePosition;

        //滑鼠左鍵壓下事件
        if (Input.GetMouseButtonDown(0))
        {
            //
        }
        else if (Input.GetMouseButton(0))
        {
            dragMgr.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
        }
        else if (Input.GetMouseButtonUp(0))
        {
            dragMgr.Set(0, 0);
        }


        dragMgr.update();
        //臉部方向的調整
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        //身體方向調整
        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        //眼睛看的方向調整
        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        live2DModel.update();
    }
Пример #12
0
    void OnRenderObject()
    {
        Matrix4x4 m1 = Matrix4x4.Ortho(
            -200.0f, 200.0f,
            200.0f, -200.0f,
            -0.5f, 0.5f);
        Matrix4x4 m2 = transform.localToWorldMatrix;
        Matrix4x4 m3 = m2 * m1;

        live2DModel.setMatrix(m3);
        live2DModel.update();
        live2DModel.draw();
    }
Пример #13
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            this.gameObject.GetComponent <Animator> ().SetInteger("Motion", 1);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            this.gameObject.GetComponent <Animator> ().SetInteger("Motion", 0);
        }

        live2DModel.update();
    }
Пример #14
0
    void Update()
    {
        if (modelUnity == null)
        {
            return;
        }
        modelUnity.setMatrix(transform.localToWorldMatrix * matrix4X4);

        if (queueManager.isFinished())
        {
            queueManager.startMotion(dMotion);
        }
        queueManager.updateParam(modelUnity);
        modelUnity.update();
    }
        void Update()
        {
            if (live2DModel == null)
            {
                return;
            }
            live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

            if (!Application.isPlaying)
            {
                live2DModel.update();
                return;
            }


            if (motionMgr.isFinished() || main != _State)
            {
                //歩き
                if (_State == Main.CharaState.Walk)
                {
                    live2DModel.setParamFloat("Param3", -1);
                    live2DModel.setParamFloat("Param7", 0);

                    motionMgr.startMotion(motions[0]);
                }
                //走り
                else if (_State == Main.CharaState.Run)
                {
                    live2DModel.setParamFloat("Param3", -1);
                    live2DModel.setParamFloat("Param7", 0);

                    motionMgr.startMotion(motions[1]);
                }
                //停止
                if (_State == Main.CharaState.Wait)
                {
                    //live2DModel.setParamFloat("Param3", -1);
                    motionMgr.startMotion(motions[2]);
                    //motionMgr.stopAllMotions();
                }
            }

            main = _State;

            motionMgr.updateParam(live2DModel);
            live2DModel.update();
            live2DModel.draw();
        }
Пример #16
0
        void Update()
        {
            //if (live2DModel == null) load();
            if (live2DModel == null)
            {
                return;
            }
            live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
            if (!Application.isPlaying)
            {
                live2DModel.update();
                return;
            }

            double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
            double t       = timeSec * 2 * Math.PI;

            live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

            //
            live2DModel.setParamFloat("PARAM_ANGLE_X", PARAM_ANGLE.x);
            live2DModel.setParamFloat("PARAM_ANGLE_Y", PARAM_ANGLE.y);
            live2DModel.setParamFloat("PARAM_ANGLE_Z", PARAM_ANGLE.z);
            live2DModel.setParamFloat("PARAM_EYE_L_OPEN", PARAM_EYE_L_OPEN);
            live2DModel.setParamFloat("PARAM_EYE_R_OPEN", PARAM_EYE_R_OPEN);
            live2DModel.setParamFloat("PARAM_EYE_BALL_X", PARAM_EYE_BALL_X);
            live2DModel.setParamFloat("PARAM_EYE_BALL_Y", PARAM_EYE_BALL_Y);
            live2DModel.setParamFloat("PARAM_BROW_L_Y", PARAM_BROW_L_Y);
            live2DModel.setParamFloat("PARAM_BROW_R_Y", PARAM_BROW_R_Y);
            live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", PARAM_MOUTH_OPEN_Y);
            live2DModel.setParamFloat("PARAM_MOUTH_SIZE", PARAM_MOUTH_SIZE);

            live2DModel.setParamFloat("PARAM_MOUTH_FORM", 0.0f);
            //

            if (physics != null)
            {
                physics.updateParam(live2DModel);
            }

            if (pose != null)
            {
                pose.updateParam(live2DModel);
            }


            live2DModel.update();
        }
Пример #17
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }


        if (motionMgr.isFinished() || main != _State2)
        {
            //歩き
            if (_State2 == Enemy2State.Walk)
            {
                motionMgr.startMotion(motions[0]);
            }
        }

        if (main != _State2)
        {
            //噛みつき
            if (_State2 == Enemy2State.Attack)
            {
                motionMgr.startMotion(motions[1]);
            }
            //怯み
            else if (_State2 == Enemy2State.Stop)
            {
                motionMgr.startMotion(motions[2]);
            }
            //停止
            if (_State2 == Enemy2State.Wait)
            {
                motionMgr.startMotion(motions[3]);
            }
        }


        motionMgr.updateParam(live2DModel);
        live2DModel.update();
        live2DModel.draw();
    }
Пример #18
0
    public void Update()
    {
        float     modelWidth = live2DModel.getCanvasWidth();      //モデルのキャンバスの横幅
        Matrix4x4 m1         = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
        Matrix4x4 m2         = transform.localToWorldMatrix;
        Matrix4x4 m3         = m2 * m1;

        live2DModel.setMatrix(m3);

        //まばたきの間隔とモーションにかかる時間を設定
        eyeBlink.setInterval(6000);
        eyeBlink.setEyeMotion(100, 100, 100);
        eyeBlink.setParam(live2DModel);

        live2DModel.update();
    }
Пример #19
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }



        double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;

        if (Input.GetMouseButtonUp(0))
        {
            mouthcheck = !mouthcheck;
        }

        //テキストを読み上げているか判定
        if (mouthcheck)
        {
            mouth = (float)Mathf.PingPong(time += mouthspeed, 1);           //口動かす
        }
        else
        {
            //徐々に口を閉じる
            if (mouth > 0)
            {
                mouth -= 0.1f;
            }
        }

        live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", mouth);        //口


        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.2345)), 1);        //呼吸


        eyeBlink.setParam(live2DModel);        //目ぱち
         
        live2DModel.update();
    }
Пример #20
0
    void Update()
    {
        if (live2DModel == null && !Load())
        {
            return;
        }

        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        live2DModel.update();
    }
Пример #21
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            live2DModel.draw();
            return;
        }
        float volume = 0;

        if (smoothing)
        {
            float currentVolume = GetCurrentVolume(GetComponent <AudioSource>());

            if (Mathf.Abs(lastVolume - currentVolume) < 0.2f)
            {
                volume = lastVolume * 0.9f + currentVolume * 0.1f;
            }
            else if (lastVolume - currentVolume > 0.2f)
            {
                volume = lastVolume * 0.7f + currentVolume * 0.3f;
            }
            else
            {
                volume = lastVolume * 0.2f + currentVolume * 0.8f;
            }
            lastVolume = volume;
        }
        else
        {
            volume = GetCurrentVolume(GetComponent <AudioSource>());
        }


        live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", volume * scaleVolume);


        live2DModel.update();
    }
    // @Brief : Set position
    // @Param : vPosition   => position
    public void SetPosition(Vector3 vPosition)
    {
        transform.localPosition = vPosition;
        float fModelWidth  = m_pLive2dModel.getCanvasWidth();
        float fModelHeight = m_pLive2dModel.getCanvasHeight();
        // Memo : Matrix calculation is performed to move the model from the default drawing position
        //          to the position shown in the camera
        Matrix4x4 mOrthoProjection = Matrix4x4.Ortho(0, fModelWidth, fModelWidth, 0, -50.0f, 50.0f);
        Matrix4x4 mWorldPosition   = transform.localToWorldMatrix;

        // Centering on pivot
        mWorldPosition[13] += ((fModelHeight / fModelWidth) - 1.0f) * mWorldPosition[5];
        // Bottom to pivot
        mWorldPosition[13] += (fModelHeight / fModelWidth) * mWorldPosition[5];
        Matrix4x4 mPosition = mWorldPosition * mOrthoProjection;

        m_pLive2dModel.setMatrix(mPosition);
    }
Пример #23
0
    void Update()
    {
        float     modelWidth = live2DModel.getCanvasWidth();
        Matrix4x4 m1         = Matrix4x4.Ortho(
            0, modelWidth, modelWidth,
            0, -50.0f, 50.0f);
        Matrix4x4 m2 = transform.localToWorldMatrix;
        Matrix4x4 m3 = m2 * m1;

        motionManager.updateParam(live2DModel);
        if (live2DModel == null)
        {
            return;
        }

        live2DModel.setMatrix(m3);
        live2DModel.update();
    }
Пример #24
0
 private void OnPostRender()
 {
     if (live2DModelUnity == null)
     {
         return;
     }
     live2DModelUnity.setMatrix(base.transform.localToWorldMatrix * live2DCanvasPos);
     if (!IsStop || isOneDraw)
     {
         motionMgr.updateParam(live2DModelUnity);
         live2DModelUnity.update();
         live2DModelUnity.draw();
         isDrawed = true;
         if (motionMgr.isFinished() || isOneDraw)
         {
             isOneDraw = false;
         }
     }
 }
Пример #25
0
 /*模型参数校正*/
 void Update()
 {
     if (Input.GetKeyDown(QUIT))
     {
         #if UNITY_EDITOR
         UnityEditor.EditorApplication.isPlaying = false;
         #else
         Application.Quit();
         #endif
     }
     //退出程序监听()
     live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvansPos);
     //转换矩阵
     Motion();
     //动作实现
     DragMove();
     live2DModel.update();
     //更新画板
 }
Пример #26
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_ANGLE_X", (float)(30 * Math.Sin(t / 3.0)));

        live2DModel.update();
    }
Пример #27
0
    void OnRenderObject()
    {
        if (live2DModel == null)
        {
            load();
        }

        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);


        if (!Application.isPlaying)
        {
            live2DModel.update();
            live2DModel.draw();
            return;
        }

        dragMgr.update();
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        live2DModel.update();
        live2DModel.draw();
    }
Пример #28
0
    void Update()
    {
        if (_live2DModel == null)
        {
            _Load();
        }
        _live2DModel.setMatrix(transform.localToWorldMatrix * _live2DCanvasPos);

        if (!Application.isPlaying)
        {
            _live2DModel.update();
            return;
        }

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        _live2DModel.setParamFloat("PARAM_ANGLE_X", (float)(30f * Math.Sin(t / 3.0)));


        _live2DModel.update();
    }
Пример #29
0
    void Update()
    {
        //if (Input.GetButtonDown("Fire1"))
        //{
        //    motion = Live2DMotion.loadMotion(mtnFiles[2].bytes);
        //    //motion.setLoop(true);
        //    motionManager.startMotion(motion, false);
        //    Debug.Log("Fire1");
        //    //motionoff = true;
        //}
        //if (Input.GetButtonDown("Fire2"))
        //{
        //    motion = Live2DMotion.loadMotion(mtnFiles[1].bytes);
        //    //motion.setLoop(true);
        //    motionManager.startMotion(motion, false);
        //   // motionManager.stopAllMotions();
        //    Debug.Log("Jump");
        //   // motionoff = true;
        //}


        float     modelWidth = live2DModel.getCanvasWidth();
        Matrix4x4 m1         = Matrix4x4.Ortho(
            0, modelWidth, modelWidth,
            0, -50.0f, 50.0f);
        Matrix4x4 m2 = transform.localToWorldMatrix;
        Matrix4x4 m3 = m2 * m1;

        motionManager.updateParam(live2DModel);
        if (live2DModel == null)
        {
            return;
        }
        //live2DModel.setParamFloat("PARAM_WEAPON01", 1.0f);
        live2DModel.setMatrix(m3);
        live2DModel.update();
    }
Пример #30
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }
        if (motionMgr.isFinished())
        {
            SetMotion(Live2DMotion.loadMotion(motionFiles[0].bytes));
        }

        //double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;
        //live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)(2 * Math.Sin(t / 0.5)));

        //Debug.Log(live2DModel.getParamFloat("PARAM_MOUTH_OPEN_Y"));
        motionMgr.updateParam(live2DModel);

        //live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)(2 * Math.Sin(t / 0.5)));
        //Debug.Log(live2DModel.getParamFloat("PARAM_MOUTH_OPEN_Y"));
        /*先播放mtn文件,再setParamFloat,不然会被mtn文件覆盖*/
        if (!GameParam.isTalkEnd)
        {
            //Debug.Log(GameParam.amplitude);
            live2DModel.setParamFloat("PARAM_MOUTH_FORM", (float)1f);
            live2DModel.setParamFloat("PARAM_MOUTH_SIZE", (float)0.8f);
            live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)GameParam.amplitude);
        }
        live2DModel.update();
    }