0 Members and 1 Guest are viewing this topic.
switch (input) { case KeyCode.Left: nextX = -1; break; case KeyCode.Right: nextX = 1; break; case KeyCode.Up: nextY = -1; break; case KeyCode.Down: nextY = 1; break; } X = X + nextX * speed; Y = Y + nextY * speed; nextX = 0; nextY = 0;
if (nextX != 0.f && nextY != 0.f){ nextX *= 0.707106781f; // == sqrt(2) / 2 nextY *= 0.707106781f;}