• 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 ODNSEV7N · Sep 03, 2013 at 12:58 PM · transform.position

How would I move one object the same distance, on each finger swipe?

I have been looking around for quite a while now, and can't seem to find any solutions that are straight forward.

I have a Quad, that moves to a certain point on the x axis, when i swipe right. the same quad moves the opposite way, (back to where it was), when i swipe left.

Its only a "one swipe" action though, as you can see in my script.

 var Slideleft : GameObject;
 
  
  
 function Update () { 
 
     for (var touch : Touch in Input.touches)
          var touchDelta : Vector3 = Input.GetTouch(0).deltaPosition;
         
         if (touchDelta.x >6) {
             Slideleft.transform.position = Vector3 (-0.19504918, 0.5, 2); 
             Debug.Log ("rightswipe");
             
     }
         if (touchDelta.x <-6) {
             Slideleft.transform.position = Vector3(0.4681461, 0.5, 2);
             Debug.Log ("leftswipe");
 
     
  }
 }

So here it moving to the exact position (0.4681461, 0.5, 2)

I have been wanting it to move on the x axis, in steps. Il try explain better.

Lets say I press a button "LEFT", and it moves a plane to the left, just a tad. If I press "LEFT" again, it nudges the object to the left again..just a tad".

If i press "RIGHT" it moves the same distance as left..but of course..Right. The more I press it, the more its nudged.

  1. units on the x axis is how much I want it to nudge each time to be precise.

( from the middle to the left )

Help would be greatly appreciated.

Cheers, Tim.

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
0
Best Answer

Answer by PAEvenson · Sep 03, 2013 at 06:26 PM

Im not really sure what exactly youre looking for....maybe something like this:

  Slideleft.transform.position += Vector3 (0.5, 0, 0); 
 
 and
 
  Slideleft.transform.position -= Vector3 (0.5, 0, 0); 
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 ODNSEV7N · Sep 04, 2013 at 01:34 PM 0
Share

That's exactly what I'm after! Thanks man.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Help with inheritance to show GUI 1 Answer

unwanted movements when camera follows object 0 Answers

Why can't I get the transform from an instantiated object? 1 Answer

Problem with objectpooling and getting NullReference Exception 1 Answer

Doesn't Instantiate at the assigned EmptyObject 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