Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by FindOut · Aug 14, 2013 at 10:47 AM · mobilephone

About Drag Object or Map on mobiles

Hello everybody, i don not understand how to drag map on mobiles,it effect like Game (my singing monster) and how to write code with C# . What to do in code at TouchPhase is Began 、TouchPhase is move and TouchPhase is End . i want to move my camera .i hope give me some suggestions,thanks. my english so bad,so....... thanks!

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

2 Replies

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

Answer by Shrikky23 · Aug 16, 2013 at 05:23 AM

if(TouchPhase.Begin) (when you touch the object) - Assign the x,y position of touch position to the (x,y) position of the object that you want to drag.... if(TouchPhase.Moved) do the same , that is the update of the value of object's x,y as the touchposition's x,y ... and then in TouchPhase.End do nothing.

PS:Lets not forget, if yours is a 3D game.Try assigning the z value of 0.... Else check the functions like Camera.ViewportToWorldPoint and other similar features in the camera.

If your camera is Looking at the object, the camera should move along with the object. Else increment/decrement the position of Camera based on the direction of swipe. (hard codin)

Hope this helps

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 FindOut · Aug 20, 2013 at 02:09 AM 0
Share

thanks for your help,You describe in great detail。

avatar image
0

Answer by Yokimato · Aug 14, 2013 at 12:28 PM

You can use Touch.position and translate it to world coordinates. If its touching whatever you need, you then pay attention to TouchPhase "moved" so you can update whatever you're dragging with the new position. Lastly, watch for the end call too, so you can stop dragging completely. Of course you'll want to wire up "begin" to start the process all together.

Comment
Add comment · Show 2 · 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 FindOut · Aug 16, 2013 at 03:55 AM 0
Share

i got it ,Thanks for your help. i have another questions.how to Smooth transition zoo$$anonymous$$g camera size, i was doing like this :"size += Time.deltaTime * speed",but it not smooth, and how to do ?$$anonymous$$athf.Lerp it does not work

avatar image Yokimato · Aug 16, 2013 at 04:16 AM 0
Share

probably best left for a new question. please mark this answer as accepted if it worked please.

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

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

Unity web player plugin for mobile browser 1 Answer

Android Back (or Escape) button isn't being recognized. 3 Answers

How to make lane switching in mobile endless runner using UI buttons? 1 Answer

mobile developement 1 Answer

Why don't the OS buttons lower when the game is playing? 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