MoveTowards only seems to be working on 1 axis rather than both - MoveTowards only working on the x axis? Seems to be ignoring the y axis...

Ok, so I’m making a 2D game within a Canvas. Firstly I instantiate a Panel with a grid layout.


Then I instantiate a bunch of buttons(Bubble(Clone)) with 1 child(Bubble Letter(Clone)) - the child of this button is what I’m trying to move into place on the grid. The runtime hierarchy looks like this:
134559-screenshot-114.jpg


The code I’m using only moves the object on the x-axis - the y axis position stays the same. I’m running this within Update():

transform.GetChild(0).position = Vector2.MoveTowards(transform.GetChild(0).position, canvas.transform.GetChild(6).GetChild(0).position, flySpeed*Time.deltaTime);

Any help or ideas will be much appreciated.

Many Thanks

Ok figured it out - to make it work at least!

 transform.GetChild(0).position = Vector2.MoveTowards(transform.GetChild(0).position, canvas.transform.GetChild(6).GetChild(0).position, flySpeed*Time.deltaTime);

Rather than moving the child I just moved the parent - it’s not ideal, but it’s working - if anyone knows how to get the child object only to move to the correct place I’d be interested to know.

Thanks