Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jinougeration · Jun 22, 2018 at 09:27 PM · gameobjectlevelsequencesolutionfinish

How to check a sequence of gameobjects and tell if it was correct or not?

Hey everyone! Lately I came across an idea I couldn't realize on my own yet, sadly. So in my little game you have to redraw pictures of symbols, which have several so-called tracing points (2D polygone collider) placed on important points of the symbols. Ingame the mouse can draw over these symbol-templates and the name of the overdrawn tracing point will appear in the console log. So far so good. Now the last complicate step is to add the functionality of checking the tracing points, if they actually got overdrawn in the right sequence. Right now I have no idea how to realize that and hope someone kinda understand what I'm talking about and how a solution could look like.

Every symbol is a simple gameobject with 2D polygone collider and the image with the template on it. A second gameobject is the symbols child in the hierachy, which has the tracing points as children of the child. The tracing points have 2D ploygone collider, as already said above. This is how the script for the tracing points looks like for the debug.log right now:

 using UnityEngine;
 using System.Collections;
 
 public class TracingPoint : MonoBehaviour {
 
     void OnMouseEnter (){
         if (Input.GetMouseButton (0)) {    
     
             Debug.Log (name);
         }
     }
     // Use this for initialization
     void Start () {    
     }
     
     // Update is called once per frame
     void Update () {    
     }
 }

I thought about giving the first child a script for an gameobject array. Then I could drag and drop the children of it in there in the right order ..sadly I have no idea if this thought is even near of a possible solution @_@ ..just hope someone can help somehow.

Thank you in advance!!! ^ ^ Btw ..if somethings is not clear pls ask!

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 Hellium · Jun 23, 2018 at 09:03 PM 0
Share

Check the solution I gave here:

https://answers.unity.com/questions/1479333/how-do-you-check-if-an-instance-of-an-object-has-b.html

The principle is the same except the objects had to be clicked one after the other, but I am sur you can easily tweak the scripts to handle mouse over.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by MonkeyHood · Jun 24, 2018 at 03:26 AM

 using UnityEngine;
 
 public class TracingPoint : MonoBehaviour
 {
     //This is a number representing when this TracingPoint should be pressed
     //First, second third, etc
     public int OrderId;
 
     //Set this in the inspector
     public TracingPointOrderValidator Validator;
 
     void OnMouseEnter()
     {
         if (Input.GetMouseButton(0))
         {
             Debug.Log(name);
             Validator.TracingPointPressed(OrderId);
         }
     }
     // Use this for initialization
     void Start()
     {
     }
 
     // Update is called once per frame
     void Update()
     {
     }
 }

This script will check if the tracing points were pressedin order.

 using System.Collections.Generic;
 using UnityEngine;
 
 public class TracingPointOrderValidator : MonoBehaviour
 {
     public TracingPoint[] TracingPoints;
 
     private List<int> pointsPressedOrder = new List<int>();
 
     public void TracingPointPressed(int pointId)
     {
         pointsPressedOrder.Add(pointId);
     }
 
     //Call this when you want to validate the order of the points
     public bool ValidatePressedOrder()
     {
         //check that we have
         bool pointsInOrder = true;
 
         //check that we have pressed each Tracing point, otherwise it can't possibly be in order
         if (TracingPoints.Length == pointsPressedOrder.Count)
         {
             for (int i = 1; i < pointsPressedOrder.Count; ++i)
             {
                 if (pointsPressedOrder[i] != i)
                 {
                     pointsInOrder = false;
                     break;
                 }
             }
         }
         else
         {
             pointsInOrder = false;
         }
 
         Debug.Log("Valid order: " + pointsInOrder);
 
         return pointsInOrder;
     }
 }
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 Jinougeration · Jun 24, 2018 at 08:31 PM 0
Share

Wow ..I'm without words. As far as I understand the scripts, it's exacly that what I tried to imagine of! ^ ^ Well, the console don't want to spit out the message, if it's actually the right order, but I'm pretty sure I will get it to work. Thank you very much for your help, I appreciated it! :)

avatar image
0

Answer by hectorux · Jun 23, 2018 at 11:35 AM

You will always have to set the proper order by ordering all in hierarchy and using the transform.GetComponentInChildren wich will give you all the transform in the hierarchy order. Or making an array in order(both the same, the transform more automatic)

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 Jinougeration · Jun 23, 2018 at 08:51 PM 0
Share

I have all tracingpoints in proper order and I kinda unterstand the transform.GetComponentInChildren, but I just cannot transfer it to my idea/problem, sry. For everything I programmed, yet, I always had to rely on tutorials, because I don't understand most of the program$$anonymous$$g-stuff, sadly. I appreciate your comment, :) but I guess I need a script as example. :(

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

134 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to restart a "prefab'd" level? ;) 0 Answers

Enter next level 1 Answer

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

How do I finish a level and send the player to the next? 3 Answers

Load a scene/level when enemy is close... 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