I have 4(four) empty gameObject in my scene which i used as move points.
I just need my player gameObject to move towards the particular gameobject.
I have stored the gameobjects transform in a array having size 4.
void MoveTowardPoint()
{
if (transform.position.x > 0f && readyFornextmove)
{
rb.MovePosition(movepoint[0].position);
}
else if (transform.position.x < 0.5f && readyFornextmove)
{
rb.MovePosition(movepoint[1].position);
}
else if (transform.position.x < 1f && readyFornextmove)
{
rb.MovePosition(movepoint[2].position);
}
else if (transform.position.x < 1.5f && readyFornextmove)
{
rb.MovePosition(movepoint[3].position);
}
}
i just made the bool value readyfornextmove as true but it only moves the first time again if i press horizontal input buttons it gets stuck in the first place itself.
All i need is the move to each points when reach at paticular transform position. I know i can be done easily using Vector2.MoveToward or Lerp or rb.MovePosition. but i not interested in it. please help.