So I’ve got the MoveTowards working in a way that was unexpected. If I drive the player all the way to the targetThingy then the reverse MoveTowards stops working, effectively trapping me right next to the target. If I keep away from the target its fine and I can move backwards.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public GameObject targetThingy;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float step = 3 * Time.deltaTime;
if (Input.GetKey(KeyCode.A))
{
transform.RotateAround(targetThingy.transform.position, new Vector3(0, 0, 1), 200 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D))
{
transform.RotateAround(targetThingy.transform.position, new Vector3(0, 0, -1), 200 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.W))
{
transform.position = Vector2.MoveTowards(transform.position,targetThingy.transform.position, step);
}
if (Input.GetKey(KeyCode.S))
{
transform.position = Vector2.MoveTowards(transform.position, targetThingy.transform.position, -step);
}
}
}