EasyTouch使用相關筆記
阿新 • • 發佈:2018-11-08
1.EasyTouch事件:On Move(Vector2 v)
當Camera不為Vector.zero時,會導致人物移動看起來不是正對攝像機,需要做一個轉換:
//以Camera正方向為準,轉換目標座標
pos = Quaternion.LookRotation(new Vector3(camera.transform.forward.x, 0, camera.transform.forward.z)) * pos;
public Transform camera; Transform player; Vector3 pos; public void MoveInJoyStick(Vector2 inputPos) { if (inputPos.y != 0 || inputPos.x != 0) { if(camera==null) { camera = Camera.main.transform; if (camera == null) return; } if(player == null) { player=GameObject.Find(NetData.GetUnitData(AccountInfo.UUID, AccountInfo.char_uid).nickname).transform; if (player == null) return; } pos = new Vector3(inputPos.x, 0, inputPos.y ); //以Camera正方向為準,轉換目標座標 pos = Quaternion.LookRotation(new Vector3(camera.transform.forward.x, 0, camera.transform.forward.z)) * pos; pos = new Vector3(player.position.x + pos.x, player.position.y, player.position.z + pos.z); //同步位置 UIMgr.GetAssetInfo().MycharController.CmdTouchProcess(pos); } }