I need your suggestions about how to approach this problem
Hello all, I know the title does not say much about my question but thanks for reading this far.
We are making a game that players try to create same (maybe almost same) image that we provide them before with some colourfull cards.
For example, lets say we give 5 cards to player and ask them to create this image with them
How can we control if the player placed the cards in right order?
I am thinking some sort of grid system but things get complicated too quickly with a grid system. maybe I can try to use some kind of image recognizing to check if player created the right image (maybe with Open cv ?) but I 've never done it before. So what is your suggestion?
Hi, I don't have any full solution to do this, just an idea to investigate: did you think about Raycast ? Unity provide Raycast functions that allow you to know what is the "first" collider touch by the ray: https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
raycast is the first thing that came to my $$anonymous$$d it first. and its still a viable way to go in fact, thanks for the suggestion.
Why don't you just compare the SiblingIndex of the cards placed by the player and compare them to the order you gave when building the "pattern"?
good mention, could be viable way to go if its mixed with some basic grid system. thanks
The grid system may not be necessary, just compare the distance between the card in the pattern and the card placed by the player.
Answer by IgorAherne · Nov 17, 2017 at 11:54 AM
Yes, grid system would be required here, to verify the cards are placed in the correct locations
How can we control if the player placed the cards in right order? It's simple, - no need for openCV hahahah
structure:
Recall, when working with UI elements (children of Canvas), they are drawn top down
- Canvas
----ImageA
----ImageB
--------ImageX
----ImageC
The order in which unity draws them is A, B, X, C
As user places cards, parent them under canvas. Once user placed all cards, compare if it matches with intended hierarchy (A, B, X, C) etc
non-ui visualization: if you are dealing with more complex thing (non-UI), to visualize them you can also look into shader draw order. However, comparing with hierarchy structure to see if player won the game would still be a must.
Answer by Zodiarc · Nov 17, 2017 at 03:21 PM
As for the order problem:
Use an ortographic camera, for every card the player places increase the Z position value for the next card. After all cards are placed you can check the z values with the z values of the correct solution. Due to higher z values the card overlap will also be correct.
Your answer
Follow this Question
Related Questions
AR face Augmentation in Unity 0 Answers
Issue with WorldToCell and Tilemaps. 0 Answers
computer vision (openCV) to create / control 2D - colliders....? 0 Answers
MonoDevelop suggestions framework/references 0 Answers
weird results when using RGBToHSV 0 Answers