Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 TheNinjassin · Mar 02, 2015 at 08:17 PM · gesture

Gesture Recognition, determining shapes

Hi guys,

So at the moment i'm creating a game in which the user draws runic symbols to cast spells (similar examples would be the magic in infinity edge or the gameplay mechanic of magic touch)

so at the moment i'm using a linerenderer to draw the user input. I'm storing the vector3 co-ordinates of the screen space in a list to record the user input. I was wondering what the most effective way to work out if the user has drawn a square / swirl / triangle is etc. Is it advisable to reduce the number of co-ordinates to a smaller number before trying to work this out and then calculating the number of angles within a certain range or... what would be the best way to do this?

sorry if this is a dumb question. just any pointers. In case you need to know i'm most comfortable writing in c#.

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
2

Answer by siaran · Mar 02, 2015 at 11:05 PM

If you want to calculate the number of angles in a certain range for a user-drawn line, you might not want to count very small ones, as those were likely intended to be a straight line. You'll have to experiment a bit on where you'll draw the line between 'angle' and 'not an angle', and it won't be foolproof.

What you will then probably want to do is store the angles you end up with in-order in an array or list (instead of the vertex positions - although you can start with those and work out where and what your angles are later), then compare with pre-stored lists of angles that define your shapes (with some margin for error). You may also want to check if the shape was closed, i.e. if your last vertex is close to your first.

I have no idea how you'd recognize a circle or any other shape with a curve in it though. (I suppose you could try drawing some, see what kind of angles you get and see if you get a result that's useable but I have some doubts on how well that would work).

Alternatively, you could look into some machine learning pattern recognition methods but...that might be a bit much. Maybe just stick to 'edgy' shapes.

Comment
Add comment · Show 3 · 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 TheNinjassin · Mar 03, 2015 at 02:42 AM 0
Share

Hi, many thanks for your reply. That was what I was thinking of doing but I was wondering how it would be best to convert the co-ordinates into angles because there will be a lot of co-ordinates in each angle is it best to reduce the number of co-ordinates by the amount of integrity to the shape or is there a way to get the angle as a generalisation from the co-ordinates in the area. What's the best way to do that?

Once again many thanks.

avatar image TheNinjassin · Mar 07, 2015 at 11:55 AM 0
Share

Okay so I was thinking of tracking the direction vector using (x',y')=(x/r,y/r) where r=sqrt(x^2+y^2) so that it only factors direction and then record the direction vector leading upto each point and once it starts changing record that as a bool that the user is changing direction and then when the vector normalises again that's the end of the corner. Then maybe apply an algorithm to reduce the number of co-ordinates to 3 (since there will be a start, corner point, and end in the user input) so that I can work out the angle and stuff. Is this over complicating the situation? Is there a better way to do it?

Thanks community

avatar image siaran · Mar 08, 2015 at 02:40 PM 1
Share

Hmm, what you could do ins$$anonymous$$d is simply track the direction between frames, and if it is significantly different, you add the angle between them to your list of angles? No idea if that would really work, just an idea I had.

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

Rotate object based on angle between two touch positions 2 Answers

Swipe Android 1 Answer

Projection of Swipe Onto Character Plane (Perspective) 1 Answer

Kick with Kinect 1 Answer

Swipe & gesture controls for android 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