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 Peterwerd · Oct 20, 2014 at 10:30 AM · touchscreendrawcompareicons

Draw a circle on touchscreen

Hey everyone,

I once played this nice little game on a smartphone. The player had to draw a circle with his finger on the touchscreen. The circle was drawn visible on the screen and then the player was given feedback on how accurate the circle was.

So I would like to know how to best approach something like that.

Getting Input from the finger and drawing a symbole

Checking the accuracy of the drawing and giving feedback.

I'm not looking directly for code (but always welcome;) but rather a pointer in the right direction.

Thank you.

Comment
Add comment · Show 1
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 _Yash_ · Oct 20, 2014 at 12:14 PM 0
Share

Do we know the center of circle around which user is going to draw a circle?

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by awest · Oct 20, 2014 at 02:00 PM

I start tackling that problem by taking vector points every so often from when the touch starts to when the touch ends. You could use Camera.ScreenPointToRay and LineRenderer. Those can give you a connect the dots effect (with or without dots). When the touch ends you can auto complete by accessing the first vector point.

If you want to fill in the circle perhaps you can generate a mesh/2D shape, but I have little experience in that.

To check accuracy, get the center of the drawn circle. Take the radius using each vector point. The closer to average radius each one is means the more perfect the circle is.

I'm sure there is an advanced formula that takes each point and the preceding point and figures out where the next one should be based on the difference between them and the diameter of the circle and something else, but that may be overkill.

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 Peterwerd · Oct 27, 2014 at 01:01 PM 0
Share

Hey Thanks for your answer. Good Idea. Would you go and say something like get the position of the touch every so often (frame/time) to create the connect the dots effect?

At the moment I'm tryong out to get the correct touch.position. I thought I could use the touch.position to start the line renderer at the correct position but somehow the world space and the touch.position are not working correct together (my instatiated object is always to far off).

avatar image awest · Oct 30, 2014 at 06:36 PM 0
Share

Yeah, maybe log the touch every second or two. $$anonymous$$ake it an easily adjustable variable so you can test and tweak.

Touch inputs register on in 2D pixel space so it has to be converted to a unity world space. There are a few good methods to do that and many tutorials on Unity answers. I prefer using the ScreenPointToRay method of whichever camera you are using.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

draw and compare 1 Answer

Smooth draw curve line 0 Answers

gui draw rexture problem 1 Answer

Procedural Mesh 1 Answer

How to call Graphics.DrawTexture() in Update 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