Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 rimawi · Dec 06, 2016 at 08:41 PM · androidswipe

projectile speed and Direction different in some devices

Hi, I am working on a 3d Paper toss game. The game works fine on my android and some other devices.. but i tested it on Samsung galaxy tablet and a Samsung phone. the paper(Projectile was too fast) and the swipe direction is way off. - so the question how can i make the script below behaves the same on all Android devices Thank you

  void Update()
     {
         
 
         if (shootEnable && Gotothrow)
         {
            
             if (Input.touchCount > 0)
             {
                 var touch = Input.touches[0];
                 switch (touch.phase)
                 {
                     case TouchPhase.Began:
                      
                         touchStart = touch.position;
                         break;
 
                     case TouchPhase.Moved:
                         if (Mathf.Abs(touch.position.x - touchStart.x) < comfortZone)
                         {
                             couldBeSwipe = false;
                         }
                         else
                         {
                             couldBeSwipe = true;
                         }
                         break;
 
                     case TouchPhase.Stationary:
                         if (Mathf.Abs(touch.position.x - touchStart.x) < comfortZone)
                         {
                             couldBeSwipe = false;
                         }
                         break;
 
                     case TouchPhase.Ended:
                         float swipeDist = (touch.position - touchStart).magnitude;
                         swipeDist= swipeDist /2.0f;
                         
                         //couldBeSwipe
                         if (couldBeSwipe || swipeDist > comfortZone)
                         {
                             GetVelocity = false;
                             touchEnd = touch.position;
 
                          GameObject ball = Instantiate(ballPrefab, basetothrow.position, Quaternion.identity) as GameObject;
                         
                         
                             GetAngle();
                            
                          ball.GetComponent<Rigidbody>().velocity=(new Vector3((worldAngle.x/-2), (swipeDist * Time.fixedDeltaTime), (swipeDist * 3 * Time.fixedDeltaTime)));
                          
                         }
                         break;
                     default:
                         break;
 
 
                 }//end switch case
                 
             }
         }
       
     }


  

  
 void GetAngle()
 {
    
     worldAngle = this.GetComponent<Camera>().ScreenToWorldPoint(new Vector3(touchEnd.x, touchEnd.y + 50f, ((this.GetComponent<Camera>().nearClipPlane - 73.0f))));
 }
   
Comment
Add comment · Show 4
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 rimawi · Dec 06, 2016 at 09:18 PM 0
Share

if you have an android : you can see the issue by downloading it... iyt is not a complet game yet i put it up for QA purposes.. thanks again https://play.google.com/store/apps/details?id=com.abgames.paperfuss

avatar image Bryangs rimawi · Dec 06, 2016 at 09:38 PM 0
Share

$$anonymous$$aybe it's lag?

avatar image rimawi Bryangs · Dec 06, 2016 at 10:31 PM 0
Share

no, it goes faster rather than slower

avatar image roman_sedition · Dec 07, 2016 at 01:12 PM 0
Share

$$anonymous$$aybe it's because you are using Time.fixedDeltaTime ins$$anonymous$$d of Time.DeltaTime, and the fixedDeltaTime is making it go faster because the other device has a significantly faster processor and therefore has a smaller fixedDeltaTime.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by RetroZelda · Dec 07, 2016 at 12:55 PM

could be since Touch.position is in pixel coordinates, the the higher the screen's resolution is, the more pixels will be traveled when swiping. You could try scaling the swipe distance to accommodate different resolutions.

Comment
Add comment · Show 1 · 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
avatar image rimawi · Dec 07, 2016 at 01:44 PM 0
Share

Thank you for your reply.. what do you mean exactly. 1-divide swipe distance by some number 2-use width and height of the screen to generate a number and divide the swipe distance please explain..also if you can add short line of code or example that will be great

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

101 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

Related Questions

Falling Character needs its position reset after swipe 1 Answer

Flick object using up swipe iOS/Android 2 Answers

Swipe control for circle (Can do swipe left/right) 2 Answers

.NET System ticks on Android - what am I doing wrong? 0 Answers

please please please very urgent, can someone convert this script for android swipe 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