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 /
avatar image
1
Question by rgaliu · May 04, 2014 at 04:21 PM · drag

Drag an object from the start of a path to end

I am trying to figure out a way that I can drag an object from the start of a path to the end. For example, if I had a path in the shape of an "S", the object would be at the bottom of the "S" and the user would have to drag the object along the "S" to get the object to the top. If the user's finger or mouse leaves the path then the object will not move until the user touches it again and continues to follow only the path. It would be very similar to dragging a ball through a maze, except its not a maze its just a clear path. Very similar to something like this:

https://www.youtube.com/watch?v=UuK-9xlNUPg

I just figured using an "imaginary" object would be the way to go trying to design a game like this, but if there's a better way to trace a path with your finger like this game, im open to it also. 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kumo-Kairo · May 04, 2014 at 05:15 PM

First thing that came to my mind - using bezier curves. Each curve only consists of several "key points", but they "snap" to each other perfectly, you can actually use Cubic bezier curves for smooth paths and Linear curves for paths like in Flaming Finger.

I explained how to make a chain of bezier curves here (it's AS3 question, but ideas are all the same, you just connect your current ending point to the first point of the next curve (or line if you use linear bezier curve)

So you just calculate current chain index (or total percentage of the path to follow). If you will drag your object along these bezier curves, it will create a great smooth feeling, and it won't "unsnap" of the path as at all times you just copy the coordinates provided by these bezier equations

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 dmko · Oct 07, 2015 at 09:33 AM 0
Share

@$$anonymous$$umo-$$anonymous$$airo I'm using curves (bezier or catmull-rom) - but how can you calculate the "current chain index (or total percentage of the path to follow" based on user touch? i.e. don't you somehow need to get the closest point on the curve to the user touch? How to do that for bezier (or catmull-rom)?

avatar image dmko · Oct 07, 2015 at 11:13 AM 0
Share

@$$anonymous$$umo-$$anonymous$$airo I'm using curves (bezier or catmull-rom) - but how can you calculate the "current chain index (or total percentage of the path to follow" based on user touch? i.e. don't you somehow need to get the closest point on the curve to the user touch? How to do that for bezier (or catmull-rom)?

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

21 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

Related Questions

A node in a childnode? 1 Answer

Question on Negating Physics Drag 1 Answer

New UI Drag Event 1 Answer

2d rigidbody drag on x, y axis 0 Answers

Click and drag - Object go through other objects when dragging 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