- Home /
How to freeze an action on button click?
I have built a 3D game where i have a character playing around and jumping. The character jumps when the player presses the left mouse button. On the game screen i have a pause button, it works fine But each time i press the pause the character also jumps. I want to disable jumping when i press on the pause button and make it works fine elsewhere in the game. Any help will be appreciated.
Answer by aditya · Apr 07, 2016 at 02:59 PM
disable your jump code when click is on the button's rect transform
bool disableJump; rect restrictedRect; RectTransform buttonRect
void Start(){ buttonRect = buttonRect.rect; }
void Update(){ if(buttonRect.contains(Input.mousePosition)){ disableJump = true; } }
help for rect.Contains
Your answer
![](https://koobas.hobune.stream/wayback/20220612074347im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity UI Button touching from far distance 0 Answers
How to make a Hover event on GUI.Button 6 Answers
GUI Button Question 1 Answer
How to disable button OnClick when drag on the screen with OnMouseDrag 2 Answers
Get button under mouse 1 Answer