void Update() { Vector3 targetPos = target.transform.position; Vector3 myPos = transform.position; Vector3 relativePos = targetPos - myPos; transform.rotation = Quaternion.LookRotation(relativePos); transform.Rotate(new Vector3(-75, 180, 0)); Vector3 pos = transform.position; pos.y = 81; this.transform.position = pos; if (!Application.isPlaying) { live2DModel.update(); return; } if (motionMgr.isFinished()) { motionMgr.startMotion(motion); } motionMgr.updateParam(live2DModel); live2DModel.update(); }
void OnRenderObject() { if (live2DModel == null) { return; } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); live2DModel.draw(); return; } // motion播完或是flag改變 if (motionMgr.isFinished() || mtnBehaviour.changeflg == true) { // load motion motion = Live2DMotion.loadMotion(motionFile.bytes); // 播放motion motionMgr.startMotion(motion); // 設置flag為off mtnBehaviour.changeflg = false; } motionMgr.updateParam(live2DModel); live2DModel.update(); live2DModel.draw(); }
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(); }
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); }
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); } }
// 아무것도 하지 않을 때에 실행할 모션은 무작위로 재생한다 void Idle() { // 현재의 모션이 끝난 상태라면 if (m_motionMgr.isFinished()) { // 난수를 생성한다 int rnd = UnityEngine.Random.Range(0, m_motions.Length - 1); // 모션 재생 m_motionMgr.startMotion(m_motions[rnd]); } m_motionMgr.updateParam(m_live2DModel); }
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 != _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(); }
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(); }
void Update() { if (!Application.isPlaying) { live2DModel.update(); return; } if (motionMgr.isFinished()) { motionMgr.startMotion(motion); } motionMgr.updateParam(live2DModel); live2DModel.update(); }
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; } } }
void Update() { if (motionMgr.isFinished()) { motionMgr.startMotion(motion); } for (int i = 0; i < NUM_MODELS; i++) { var live2DModel = models[i]; if (live2DModel == null) { continue; } motionMgr.updateParam(live2DModel); live2DModel.update(); } }
/// <summary> /// 更新処理 /// </summary> void Update() { // モーション再生が終了した場合 if (motionManager != null && motionManager.isFinished()) { // モーションをロードする motion = Live2DMotion.loadMotion(mtnFiles[motioncnt].bytes); // フェードインの設定 motion.setFadeIn(mtnFadeines[motioncnt]); // フェードアウトの設定 motion.setFadeOut(mtnFadeoutes[motioncnt]); // モーション再生 motionManager.startMotion(motion, false); // 音声再生 if (soundFiles[motioncnt] != null) { GetComponent <AudioSource>().clip = soundFiles[motioncnt]; GetComponent <AudioSource>().Play(); } } }
void Update() { if (motions == null || motions.Length == 0) { return; } if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetMouseButtonDown(0)) { startClickTime = Time.realtimeSinceStartup; } if (Input.GetMouseButtonUp(0) && Time.realtimeSinceStartup - startClickTime < dragWaitSeconds) { NextMotion(); } } if (motionMgr.isFinished()) { if (running) { if (loop) { motionMgr.startMotion(motions[currentMotionIndex]); } else { running = false; } } else { return; } } motionMgr.updateParam(modelComponent.model); }
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(); }
void Update() { if (live2DModel == null) { load(); } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); return; } if (motionMgr.isFinished()) { motionMgr.startMotion(Live2DMotion.loadMotion(motionFiles.bytes)); } motionMgr.updateParam(live2DModel); 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(); //Debug.Log(dragMgr.getX()+"-"+dragMgr.getY()); 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_BODY_ANGLE_Y", dragMgr.getY() * 5); 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.1f + 0.9f * Math.Sin(t / 3.0))); eyeBlink.setParam(live2DModel); if (physics != null) { physics.updateParam(live2DModel); } live2DModel.update(); }
void Update() { if (live2DModel == null) { return; } if (auto) { if (link_animator) { AnimatorStateInfo state = GetComponent <Animator>().GetCurrentAnimatorStateInfo(0); timer = state.length * state.normalizedTime; //timer = (float)GetComponent<Animator>().GetTime(); UtSystem.setUserTimeMSec((long)(timer * 1000.0f)); } else { delta_timer = (Time.time - temp_real_timer) * speed; timer += delta_timer; UtSystem.setUserTimeMSec((long)(timer * 1000.0f)); temp_real_timer = Time.time; } } bool motion_chenged = false; if (motionFile == null) { motion = null; temp_motionFile_name = ""; } else { if (temp_motionFile_name != motionFile.name) { motion = Live2DMotion.loadMotion(motionFile.bytes); motion_chenged = true; } temp_motionFile_name = motionFile.name; } if (live2DModel.getLayer() != gameObject.layer) { live2DModel.setLayer(gameObject.layer); } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); return; } if (motion != null) { motion.setLoop(true); motion.setFadeIn(0); motion.setFadeOut(0); if (motionMgr.isFinished()) { motionMgr.startMotion(motion); } if (motion_chenged) { motionMgr.stopAllMotions(); motionMgr.startMotion(motion); } motionMgr.updateParam(live2DModel); } else { motionMgr.stopAllMotions(); if (motionFile != null) { motion = Live2DMotion.loadMotion(motionFile.bytes); } } live2DModel.update(); if (live2DModel.getRenderMode() == Live2D.L2D_RENDER_DRAW_MESH) { Render(); } }
void Update() { //Debug.Log(DateTime.Now); Festival(); Timer(); //base Behavior & Motion Ctrl if (live2DModel == null) { load(); } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); //live2DModel.draw(); return; } //if (ВерныйAS.isPlaying) //{ // audioPlayerAS.volume = 0.1f; // //audioPlayerAS.mute = true; //} //else //{ // audioPlayerAS.volume = 1.0f; // //audioPlayerAS.mute = false; //} //每隔一段时间随机播放动画 //playTime += Time.deltaTime; //if (playTime >= playRate) //{ //if (motionMgr.isFinished()) //{ // motionMgr.startMotion(Live2DMotion.loadMotion(motionFile[UnityEngine.Random.Range(0, 4)].bytes)); // playTime = 0; //} //} var pos = Input.mousePosition; if (playTime < playRate) //计时器逻辑 { playTime += Time.deltaTime; } if (Input.GetMouseButtonDown(0))//点击随机播放动画和对应语音 { if (playTime >= playRate) { if (motionMgr.isFinished()) { audioClipID = UnityEngine.Random.Range(0, ВерныйAudioClipRandomIdle.Length); ВерныйAS.clip = ВерныйAudioClipRandomIdle[audioClipID]; ВерныйAS.Play(); cuAudioClipID = audioClipID; //获取当前随机到的声音ID //Debug.Log(cuAudioClipID); motionMgr.startMotion(Live2DMotion.loadMotion(idleMotionFile[cuAudioClipID].bytes)); //播放对应的动画 playTime -= playRate; } } } //else if (Input.GetMouseButtonDown(1)) //{ // if (motionMgr.isFinished()) // { // motionMgr.startMotion(motionBattle); // } //} 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() * 20); live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 20); live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10); live2DModel.setParamFloat("PARAM_EYE_BALL_X", dragMgr.getX() * 20); live2DModel.setParamFloat("PARAM_EYE_BALL_Y", dragMgr.getY() * 20); live2DModel.setParamFloat("PARAM_ikari", dragMgr.getX()); live2DModel.setParamFloat("PARAM_ikari", dragMgr.getY()); live2DModel.setParamFloat("PARAM_HAIR_FRONT", dragMgr.getX()); live2DModel.setParamFloat("PARAM_HAIR_SIDE", dragMgr.getX()); live2DModel.setParamFloat("PARAM_HAIR_BACK", dragMgr.getX()); 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(); if (live2DModel == null) { return; } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); return; } motionMgr.updateParam(live2DModel); live2DModel.update(); OnRenderObject(); }
void Update() { if (live2DModel == null) { return; } live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos); if (!Application.isPlaying) { live2DModel.update(); return; } if (motionMgr.isFinished() || main != Player.State) { //歩き if (Player.State == Main.CharaState.Walk) { live2DModel.setParamFloat("Param3", -1); live2DModel.setParamFloat("Param7", 0); motionMgr.startMotion(motions[0]); } //走り else if (Player.State == Main.CharaState.Run) { live2DModel.setParamFloat("Param3", -1); live2DModel.setParamFloat("Param7", 0); motionMgr.startMotion(motions[1]); } //素手殴り else if (Player.State == Main.CharaState.HandAttack) { //live2DModel.setParamFloat("Param3", -1); motionMgr.startMotion(motions[2]); } //鉄棒殴り else if (Player.State == Main.CharaState.BarAttack) { motionMgr.startMotion(motions[3]); } //銃攻撃 else if (Player.State == Main.CharaState.Shot) { motionMgr.startMotion(motions[4]); } //通常ダメージ else if (Player.State == Main.CharaState.Damage) { motionMgr.startMotion(motions[8]); } //銃攻撃 else if (Player.State == Main.CharaState.Down) { motionMgr.startMotion(motions[9]); } //停止 if (Player.State == Main.CharaState.Wait) { //live2DModel.setParamFloat("Param3", -1); motionMgr.startMotion(motions[10]); //motionMgr.stopAllMotions(); } } main = Player.State; motionMgr.updateParam(live2DModel); live2DModel.update(); live2DModel.draw(); }