Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
avatar image
0
Question by surfuay · Dec 26, 2018 at 03:39 PM · movementpausetouch controlstouchscreen

reading movement and screen buttons together on touch

I am having trouble "blocking" the movement of my player when I touch my pause and my unpause button. Is there a way to keep it from registering a touch on those two buttons or to make those buttons "dead zones" that dont read my touches.

Here's my movement method and the declared variables Movement() is called in the Update Method

Vector3 _myPosition;

private void Movement() { //overall movement method (time.timescale to maintain players speed throughout game) if (UIManager.uIManager.pauseMenuVisible == true) { transform.position = Vector3.Lerp(transform.position, _myPosition, _speed * Time.deltaTime);

     }
     else
     {
         transform.position = Vector3.Lerp(transform.position, _myPosition, _speed * Time.deltaTime * 1 / Time.timeScale);
     }

     if (Input.touchCount > 0)
     {
         Touch _touch = Input.GetTouch(0);
         Vector3 _touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(_touch.position.x, _touch.position.y, 10));
         _myPosition = _touchPosition;
         _animator.SetTrigger("Player_Run");

         if (_myPosition.x >= 0f && _myPosition.x <= 3.5f && _myPosition.y >= -6f && _myPosition.y <= -1.2f)
         {
             _myPosition = new Vector3(1.74f, -2.4f, 0);
         }
         else if (_myPosition.x >= 0f && _myPosition.x <= 3.5f && _myPosition.y >= -1.21f && _myPosition.y <= 2f)
         {
             _myPosition = new Vector3(1.61f, .35f, 0);
         }
         else if (_myPosition.x >= 0f && _myPosition.x <= 3.5f && _myPosition.y >= 2.01f && _myPosition.y <= 6f)
         {
             _myPosition = new Vector3(1.52f, 3.9f, 0);
         }
         else if (_myPosition.x >= -3.5f && _myPosition.x <= -.01f && _myPosition.y >= -6f && _myPosition.y <= -1.2f)
         {
             _myPosition = new Vector3(-1.84f, -3.08f, 0);
         }
         else if (_myPosition.x >= -3.5f && _myPosition.x <= -.01f && _myPosition.y >= -1.21f && _myPosition.y <= 2f)
         {
             _myPosition = new Vector3(-1.77f, 1.04f, 0);
         }
         else if (_myPosition.x >= -3.5f && _myPosition.x <= -.01f && _myPosition.y >= 2.01f && _myPosition.y <= 6f)
         {
             _myPosition = new Vector3(-1.56f, 3.76f, 0);
         }            
     }   
 }

NOTE - I am not having a problem with time.timeScale it works great. when i pause all motion stops. the problem is that when i hit the pause button before pause occurs the player will begin it's movement towards where that pause button is located and so on with the unPause button.

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

149 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

How to make basic touch screen controls 1 Answer

store the user touch input 0 Answers

Can't make cube follow the finger. 2 Answers

How to control 2 axes of object in 3d world 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