Essentially what I’m trying to do is move my object from its starting position to a different “Y” position but keeping the same “X” position. Here is my code.
private Vector2 currentPos;
private Vector2 newPos;
// Use this for initialization
void Start () {
currentPos = new Vector2 (transform.position.x, transform.position.y);
newPos = new Vector2 (transform.position.x, Random.Range (3.0f, 4.7f));
}
// Update is called once per frame
void Update () {
transform.position = Vector2.MoveTowards (currentPos, newPos, 1f * Time.deltaTime);
}
I can’t seem to get it to work at all. Any suggestions? Thanks!