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 /
  • Help Room /
This question was closed Feb 25, 2016 at 07:21 PM by Le-Pampelmuse for the following reason:

OP unresponsive.

avatar image
1
Question by Political Peace Party Studios · Dec 03, 2015 at 04:53 PM · cameraswipescrollpanning

Pan Camera Left and Right

Mobile App - I have this working, but there is one problem. Lets say I swipe to go to the left, as soon as I lift my finger off the screen, it stops panning. So users think that its bugged because they expect it to kinda keep going and slowly stop. Instead of stoping the moment you lift your finger up. Heres my code.

  using UnityEngine;

   public class ScrollCamera : MonoBehaviour
   {
 public float dragSpeed = 1;
 private Vector3 dragOrigin;
 
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {

         dragOrigin = Input.mousePosition;
         return;
     }
     
     if (!Input.GetMouseButton(0)) return;

     Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
     Vector3 move = new Vector3(pos.x * dragSpeed, 0);
     
     transform.Translate(move, Space.World);  

     var posi = transform.position;
     posi.x =  Mathf.Clamp(transform.position.x, -1.0f, 1.96f);
     transform.position = posi;


 }
 
 }


What can I do to fix this so that it keeps going when you lift your finger off the screen, then slowly stops depending on how hard you swiped left or right. It needs sort of like a momentum and friction.

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 Le-Pampelmuse · Dec 03, 2015 at 05:22 PM 2
Share

It does work as expected, only there is no smoothing of the movement to make it more appealing to users. ;)

Everyone expects the "smoothness" when swiping on touch devices, but it's not something they do automatically.

I googled "unity how to smooth fade velocity" and came to Vector3.SmoothDamp. That should do the trick.

Don't hesitate to google your questions, many of common problems or how-to questions (like this one) have already been answered or are even described in the documentation.

You would save time and the forums would'nt have so many duplicate questions posted.

Have a nice day :)

avatar image SumFortyOne Le-Pampelmuse · Dec 14, 2015 at 09:47 PM 1
Share

That's a perfect function for camera moving, thanks!

avatar image Le-Pampelmuse · Dec 14, 2015 at 09:30 PM 2
Share

Hi, just checking if you found that my answer helped. ;) If not, or only partially, feel free to ask where you have trouble.

avatar image Le-Pampelmuse · Feb 08, 2016 at 06:04 PM 2
Share

Please either accept the answer if it helped or feel free to ask where you still have problems with this. Don't leave questions open or ignore answers. That's rude ;)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

40 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

Related Questions

Cinemachine not showing up in toolbar. 0 Answers

Offset Scrolling on a plane moving with Camera 0 Answers

Camera vertically scrolling effect (scroll out) 1 Answer

Camera click and drag pan with UI elements blocking raycast 0 Answers

Swipe camera rotation controller (HELP) 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