I am trying to cancel the player movement when the pause button is pressed. Currently when the user presses pause and scrolls through the options, the player moves along with the user’s touch as well. I want to stop this. I tried out a few things, but have not been able to make it work.
Here’s my code for player movement:
void Update(){
if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Moved) {
Vector2 touchDeltaPosition = Input.GetTouch (0).deltaPosition;
transform.Translate (touchDeltaPosition.x * speed, touchDeltaPosition.y * speed, 0);
//transform.Translate (touchDeltaPosition.x, touchDeltaPosition.y, 0);
if (PausePanel.isPaused == true) {
Input.GetTouch (0).phase == TouchPhase.Canceled;
transform.Translate (touchDeltaPosition.x * 0, touchDeltaPosition.y * 0, 0);
}
}
}
Thanks alot!
– El-DeiabloCan you please file a bug report that contains a) a scene where this can be reproduced with a prefab instance and b) a screen recording of the problem happening in this scene on your machine? If you post the case number here I will take a look.
– Adam-Mechtley