// Update is called once per frame void Update() { if (m_sceneMain.IsGamePlay() == false) { return; } Vector3 vector = SceneMain.GetInput(m_initData.playerNo); rigidbody.velocity = vector * m_speed; // 歩行音を鳴らす if (rigidbody.velocity.sqrMagnitude > 0F) { walkSEObj.enabled = true; } else { walkSEObj.enabled = false; } // 移動した方向を向く if (rigidbody.velocity.magnitude > 0.01f) //ベクトルの長さが0.01fより大きい場合にプレイヤーの向きを変える処理を入れる(0では入れないので) { detective.transform.rotation = Quaternion.LookRotation(rigidbody.velocity); //ベクトルの情報をQuaternion.LookRotationに引き渡し回転量を取得しプレイヤーを回転させる } }
// Update is called once per frame void Update() { if (m_sceneMain.IsGamePlay() == false) { return; } switch (m_state) { case eState.Normal: Move(); break; case eState.Stan: m_stanTime -= Time.deltaTime; if (m_stanTime <= 0.0f) { // エフェクトを消す GameObject.Destroy(m_stunEffect); m_stunEffect = null; // 復活モーション m_animator.SetTrigger("pop"); // どこかにワープ var random = new System.Random(); var rand = random.Next(0, m_sceneMain.TresurePosDatas.Length); Vector3 pos = m_sceneMain.TresurePosDatas[rand].m_pos; pos.x += 1.0f; pos.y = 1.0f; transform.position = pos; m_rigidbody.velocity = Vector3.zero; m_state = eState.Normal; // 音を停止 m_audio.Stop(); } break; } }