I am in the very basic stage of learning unity and am in a top down 2D setting. I am trying to get my object to move left a specific number of units and then down a specific number of units and then stop, but what it is doing is just moving diagonal and does not stop.
This is the script attatched to my object.
public class Movement : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
int leg=0;
switch (leg)
{
case 0:
MoveRight(20);
leg++;
break;
case 1:
MoveDown(20);
leg++;
break;
default:
break;
}
MoveDown(20);
MoveRight(20);
}
void MoveRight(int amount)
{
for (int i = 0; i < amount;i++)
{
transform.position = new Vector3(transform.position.x + .001f, transform.position.y);
}
}
void MoveLeft(int amount)
{
for (int i = 0; i < amount; i++)
{
transform.position = new Vector3(transform.position.x - .001f, transform.position.y);
}
}
void MoveUp(int amount)
{
for (int i = 0; i < amount; i++)
{
transform.position = new Vector3(transform.position.x, transform.position.y+.001f);
}
}
void MoveDown(int amount)
{
for (int i = 0; i < amount; i++)
{
transform.position = new Vector3(transform.position.x, transform.position.y - .001f);
}
}
}