Game Development Reference
In-Depth Information
timer = 0;
TargetLocation =
WorldExtensions.GetScreenPositionFor2D(Input.GetTouch(0).position);
startedTravelling = true;
}
Traveling too far
The last snag to watch out for is when the player shoots straight through the town we are
currently prompting them about and continues going. Thankfully, this one is very easy to
handle.
We just need to check when our input has been disabled by the GUI by checking the new
inputReady
flag. If the input has only just been disabled, we do this by updating the
end of the
Update
method in our
MapMovement
script as follows:
if (!inputReady && inputActive)
{
TargetLocation = this.transform.position;
Debug.Log("Stopping Player");
}
inputActive = inputReady;
}
So, when the UI event has turned off the
inputReady
flag but has not yet been syn-
chronized with the
inputActive
flag, we simply stop the player in their tracks and fix
their target position to their current position.