Last active
November 8, 2019 22:27
-
-
Save ShiftedClock/8d12a835feb7d9c257d08a57a88b7af8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| public class PolarCharacterController { | |
| [SerializeField] private float moveSpeed; | |
| private PolarCoordinate pc; | |
| public void Awake () { | |
| pc = new PolarCoordinate(transform); | |
| } | |
| public void Update () { | |
| if (Input.GetAxis("Horizontal")) { | |
| MoveHorizontal(moveSpeed * Time.deltaTime); | |
| } | |
| if (Input.GetAxis("Vertical")) { | |
| MoveVertical(moveSpeed * Time.deltaTime); | |
| } | |
| //? Big unknown: Is the angle factor for diagonal movement the same as for a 2D CharacterController on a plane? | |
| // i.e. sqrt(2)/2 | |
| // Actually, it is strange that the further you go from the center, the faster you're moving. | |
| // But in the world of this game that actually makes sense. | |
| } | |
| public MoveHorizontal () { | |
| //? Should the logic be contained in here or in the PolarCoordinate class? | |
| //pc.angle | |
| } | |
| public MoveVertical () { | |
| //pc. | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PolarCoordinate { | |
| private float dist; | |
| public float Dist { | |
| get => dist; | |
| //TODO: set => update transform | |
| }; | |
| private float angle; | |
| public float Angle { | |
| get => angle; | |
| //TODO: set => update transform; | |
| }; | |
| private Transform transform; | |
| public PolarCoordinate (Transform transform) { | |
| this.transform = transform; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment