I’m trying to do a movement based on Pokemon Ice Movement / Slider android game.
THIS VIDEO SHOWS THE MOVEMENT: Android Slider Game App - YouTube
The move consists on when you slide to one axis, the player needs to wait to collide with the wall to have permition to do the next move.
I’m a software engineer student so I’m familiar with programming, but I’m new on Unity and game programming so I need a bit of help right now.
I already have this code:
public class PlayerController1 : MonoBehaviour {
public float MovementSpeed = 20f;
private bool prevStatusVertical;
private bool prevStatusHorizontal;
private bool moveHorizontal;
private CharacterController cc;
void Start () {
cc = GetComponent<CharacterController> ();
}
void Update () {
float forwardSpeed = Input.GetAxis("Vertical") * MovementSpeed;
float sideSpeed = Input.GetAxis("Horizontal") * MovementSpeed;
//This variables will be used to check whether player is pressing keys assigned to Horizontal and Vertical
bool statusHorizontal = Input.GetButton("Horizontal");
bool statusVertical = Input.GetButton("Vertical");
if (statusHorizontal && !prevStatusHorizontal)
moveHorizontal = true;
if (statusVertical && !prevStatusVertical || !statusHorizontal)
moveHorizontal = false;
//By default character is not moving
Vector3 speed = new Vector3 (0, 0, 0);
if (statusVertical && !moveHorizontal)
{
speed.z += forwardSpeed;
}
else if (statusHorizontal)
{
speed.x += sideSpeed;
}
prevStatusVertical = statusVertical;
prevStatusHorizontal = statusHorizontal;
cc.SimpleMove (speed);
}
}