private void moveCharacterGrid(int targetOrientation) { float moveMagnitude = 0.25f; int currentRotation = (int)Math.Round(transform.rotation.eulerAngles.y, 0); Debug.Log("current rotation" + currentRotation); Dictionary <int, Vector3> actionOrientation = new Dictionary <int, Vector3> (); actionOrientation.Add(0, new Vector3(0f, 0f, 1.0f * moveMagnitude)); actionOrientation.Add(90, new Vector3(1.0f * moveMagnitude, 0.0f, 0.0f)); actionOrientation.Add(180, new Vector3(0f, 0f, -1.0f * moveMagnitude)); actionOrientation.Add(270, new Vector3(-1.0f * moveMagnitude, 0.0f, 0.0f)); int delta = (currentRotation + targetOrientation) % 360; string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; string json = ThorChallengeInfo.RawSceneInfo[sceneName]; SceneConfigurationList sceneConfigList = JsonUtility.FromJson <SceneConfigurationList>(json); GridPoint[] gridPoints = sceneConfigList.configs [0].gridPoints; Vector3 currentPoint = nearestGridPoint(gridPoints, transform.position); Vector3 targetVector = nearestGridPoint(gridPoints, (new Vector3(currentPoint.x, currentPoint.y, currentPoint.z)) + actionOrientation [delta]); Debug.Log("got target" + targetVector); Debug.Log(targetVector == new Vector3()); // // checkMove = true; // m_CharacterController.Move (); }
override protected void Start() { base.Start(); string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; string json = ThorChallengeInfo.RawSceneInfo[sceneName]; sceneConfigList = JsonUtility.FromJson <SceneConfigurationList>(json); }