// Update is called once per frame void Update() { if (col.GetTalkFlag()) { animator.SetBool("walk", false); mode = PlayerMode.Talk; // 話す用のカメラの設定 Transform pos = null; // 子オブジェクトを全て取得する foreach (Transform childTransform in col.GetTarget().transform.parent.transform) { if (childTransform.name == "TalkTargetPos") { cameraControll.ChangeTalkMode(childTransform, cameraPos.transform); break; } } // お互いを向かい合わせる Transform target = col.GetTarget().transform.parent; Vector3 vec = target.position - this.transform.position; vec.Normalize(); Quaternion playerInv = Quaternion.Inverse(this.transform.rotation); Vector3 localVec = playerInv * vec; localVec = new Vector3(localVec.x, 0.0f, localVec.z); localVec.Normalize(); float cosine = Vector3.Dot(Vector3.forward, localVec); Vector3 axis = this.transform.rotation * Vector3.Cross(Vector3.forward, localVec); if (this.transform.position.y < 0) { axis = -axis; } Quaternion q = this.transform.rotation * Quaternion.AngleAxis(Mathf.Rad2Deg * Mathf.Acos(cosine), axis); this.transform.rotation = Quaternion.Lerp(this.transform.rotation, q, 0.3f); target.rotation = this.transform.rotation * Quaternion.AngleAxis(180.0f, Vector3.up); } else if (col.GetClear() && !col.GetTalkFlag()) { mode = PlayerMode.Clear; } else { mode = PlayerMode.Normal; } switch (mode) { case PlayerMode.Normal: NormalModeUpdate(); break; case PlayerMode.Talk: break; case PlayerMode.Clear: break; } }