Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Green-Jungle · Jul 14, 2014 at 10:10 AM · touchjumpingtouchscreenpause game

Problems with Touch Screen and Pause Game?

Hello everyone.I'm having problem.I'm making a 2d platform game.My character will jump when I touch finger on screen mobile android. But when i click on pause button of NGUI then character aslo jump and dialog pause appear .I think because touch screen's still running . Now i want to character can't jump when click on pause button that only jump when click on touch screen..how to disable touch screen before click on pause button because it always occur before when click pause button.Please help me.Thank you very much.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Green-Jungle · Jul 15, 2014 at 10:16 AM 0
Share

first thing i want to say thank you.this is my code: Class TouchScreen attached on Scene

 PlayerControl player;
     void Start () {
         player = GameObject.Find("Player").GetComponent<PlayerControl>();
     }
 
     void Update()
     {
         if (Input.Get$$anonymous$$ouseButtonDown(0))
         {
             player.UpdateJumpHandler();  //reference to UpdateJumpHandler function to Jump when touch on screen.
         }
 
      
         //else
         //{
         //    GameControler.buttonPressed = false;
         //}
 
     }

Then I have a PauseScript class attached on Camera :

 public void PauseGame()
     {
         if (!isPaused )
         {
           //  Debug.Log("Paused");
             Time.timeScale = 0.0f;
             isPaused = true;
        //     player.enabled = !player.enabled;
         //    EasyTouch.SetEnabled(false);
            // player.jumpPower = 0;
          //   pausePlayer.collider.enabled = false;
         }
         //foreach (GameObject game in gameTag)
         //{
         //    game.gameObject.collider.enabled = false;
         //}
     }
 
 
     public void ResumeGame()
     {
         if (isPaused)
         {
            // Debug.Log("Unpaused");
             Time.timeScale = 1.0f;
             isPaused = false;
             //player.jumpPower = 500f;
 
         }

I created a button by NGUI called it is Pause and attached a GameControler class :

 public void ButtonPause()
     {
         // players.jumpPower = 0;
         pause.PauseGame();
         buttonPressed = true;
       //  players.enabled = !players.enabled;
         // touch.enabled = !touch.enabled;
      //   EasyTouch.SetEnabled(false);
         //   Invoke("DelayJump", 1f);
         pauseDialog.GetComponent<TweenPosition>().PlayForward();
     }


But when I click on Pause Button on Scene then it as image below :

https://www.dropbox.com/s/ipnnbddren2623a/Untitled.png Player jump up when pause beacause touch screen's also running. Actually ,I never use Raycast to do this and I don't know use it how.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by NikunjPopat · Jul 14, 2014 at 10:14 AM

you should use OnApplicationPause() method.

Write your pause code into OnApplicationPause() method...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I move an object with my finger?[C#] 1 Answer

A touch'es state is always Began and the position doesn't change 1 Answer

Drag a ball to add force to a ball by touch screen 1 Answer

Transitioning from different number of touches causes behavior overlap 0 Answers

Unity touch not working correctly 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges