Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by matta9001 · Jul 21, 2015 at 08:56 PM · c#uimobilecontrols

Cross Platform Input touchpad acceleration

So I downloaded the cross platform input manager and i have the touchpad script on an image in the ui canvas. I have it on swipe because its probably the best way to aim in mobile fps games. However, it is not easy to aim, because it is too sensitive to aim, but far too slow to do things like make a 180 degree turn. So let's take an example like Minecraft Pocket Edition which has very good mobile fps controls. I noticed that it has acceleration so you can aim at small things while having the ability to do a 180 degree turn if you move it across the screen pretty fast. How do i apply this to Touch Pad script in cross platform input, so that you can do pinpoint aiming, while still having the ability to turn around?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by MusapKahraman · Feb 12, 2017 at 09:07 AM

This would solve your problem. Attach the script on a camera.

 using UnityEngine;
 using UnityStandardAssets.CrossPlatformInput;
 
 public class Controller : MonoBehaviour
 {
     float controlSpeed;
     public float sensitivity = 15;
     public int maxSpeed = 250;
 
     void Update()
     {
         if (Input.touchSupported)
         {
             controlSpeed = Input.GetTouch(0).deltaPosition.magnitude * sensitivity;
             controlSpeed = controlSpeed > maxSpeed ? maxSpeed : controlSpeed;
         }
         else
             controlSpeed = 3 * sensitivity;
         controlSpeed = controlSpeed * Time.deltaTime;
 
         transform.Rotate(-controlSpeed * CrossPlatformInputManager.GetAxis("Vertical"), controlSpeed * CrossPlatformInputManager.GetAxis("Horizontal"), 0);
     }
 }
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

23 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

Related Questions

How to make custom UI controls/components using C#? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Best free way to control a first person character on a mobile device 2 Answers

Rounding Numbers not consistent??? (C#) 1 Answer


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