Hey guys, I got a question. I working on a simple game, but I'm stuck at the controlls. What I want is that the player moves exactly an amount of pixels (lets say 32 pixels in mine game). So if i press up, the player must move exactly 32 pixels up. here's an example of Boulderdash wich uses what I want: http://www.youtube.com/watch?v=FiEVfa1OK_o Thanks in the advance!
I would set 2D grid and move the player between the points when they move the arrow keys rather than have a character controller.
When pressing a key you can make the player enter in a state where he ignores all inputs and moves in one direction in a specific time. I'll use units in the example because I don't know how to control the movement by pixels. Code (csharp): function Update() { if( walkToLeft == true) { // TIME CHECK if( keyTime + 1.0 > Time.time ) // 32 units per second, each movement takes 1 second { transformToMove.Translate( Vector3( -32, 0, 0) * Time.deltaTime, Space.World ); // Move function } else // Time over, end of the movement { walkToLeft = false; } } else if( Input.GetButton("Left") ) // If the player isn't walking, you can make it walk { walkToLeft = true; keyTime = Time.time; // To control the time }
the movement based on pixels will also depend on where the camera is placed. Instead of using pixels use x and z or something.