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
0
Question by Robindoo · Dec 14, 2010 at 03:53 AM · arraybooleanpointrectsequence

Detecting points touched in sequence.

Using Rect(), I created 4 points as follows. (The co-ordinates are fake for now, cause my exacts co-ordinates are too long). The points are place in a diamond shape.

var p1 = Rect(x1,y1,10,10);
var p2 = Rect(x2,y2,10,10);
var p3 = Rect(x3,y3,10,10);
var p4 = Rect(x4,y4,10,10);

This is how it will appear.

        [p1]
  [p2]        [p3]
        [p4]

The player can use their fingers to move through the points to draw symbols. For start, I allow the users to draw Lightning, ^ and inverted ^. So lets say if player touches in the following sequence : (p1,p2,p3,p4). It draws a lightning shape. The player can also draw (p1,p3,p2,p4) to draw a reflected lightning shape. For the ^, the sequence is (p2,p1,p3) or (p3,p1,p2). For the last one, (p2,p4,p3) or (p3,p4,p2).

I tried using booleans but it ended up causing some booleans to be triggered unintentionally. I heard from my friend something about getting them into arrays but I got stuck at how to detect the sequence in the array.

Anyone can help?

Comment
Add comment · Show 2
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 Justin Warner · Dec 14, 2010 at 03:56 AM 0
Share

Commenting about: Could you make empty game objects along the path that you want drawn, have the player draw, and if they have a certain success rate in the given game objects, it'll come up true true true false true, and thats 4/5 or 80 percent, above 75 percent, so you pass, so then it just counts up booleans that way, and then it could work that way... Does this make sense? If not, reply, I'll explain it further...

avatar image Robindoo · Dec 14, 2010 at 04:08 AM 0
Share

I think I can catch a little of it. But not sure how to count up the booleans.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Justin Warner · Dec 14, 2010 at 04:19 AM

Okay, Here it is explained a little more.

So, you want the player to draw a line...

X X X X X X X X X X

Above are 10 points... In order to pass, you need atleast 70 percent correct, so in other words, 7 of them must be right.

To do this, get the distance between what the user draws, and the actual game object (Represented by an X above)... Now, in the if statement to check if the distance is close enough, you can incrememnt a variable (Let's say, gotRight)...

So, when user is done drawing, whether it be pushing a button, or some other means, it checks between how many were possible (You can use http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html)

Now, that'll say how long, just use .length, and then divide the gotRight by the variable above, and that'll give you a percent. Now check whether or not that percent is >= .7, if so, then they got it right, if not, then they got it wrong...

Is that better?

Comment
Add comment · Show 5 · 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 Robindoo · Dec 14, 2010 at 05:51 AM 0
Share

It is still a little confusing. I don't really want to put too many gameobjects on the scene as what I have now is not the compiled version from my friend. I'm afraid it might cause lag issues in it.

avatar image Justin Warner · Dec 14, 2010 at 05:53 AM 0
Share

I'm almost positive an empty game object takes no time at all as it is what it is... Empty, and it doesn't have to render or anything, you're using it as a place holder...

avatar image Robindoo · Dec 14, 2010 at 06:33 AM 0
Share

But wouldnt everything be triggered lets say if the user just randomly swipe through and touches all the points?

avatar image Robindoo · Dec 14, 2010 at 07:27 AM 0
Share

another thing to take note is that if i have to use that method, i will have to attach them all to my camera as the player will be moving in manner similar to Cave Run and other similar games.

avatar image Justin Warner · Dec 14, 2010 at 02:49 PM 0
Share

That wouldn't be a problem (The camera part)...

Then, to counter messure, you could put "duds" in the scene, where you get more than 90 percent of them, then you fail... You can use the same script you'd use above, and just change the var names....

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

No one has followed this question yet.

Related Questions

question about array or list of boolean 1 Answer

Unity 3D C# - Drawing Lines On Tiles 0 Answers

Collecting Array items in order 1 Answer

String comparison, can't use false result as string. 4 Answers

How can I do a foreach loop for an array of booleans? 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