- Home /
Checking Position
*Skip to bolded text for question
Hi, all! I have a very curious problem on my hands that I hope can be solved. :) I am trying to do a Guitar Hero / Rockband type thing. I have Unity Indie (Free ;P )so instead of using 3D elements, I am using Blender to model 3D elements, and render them and then use them as GUI Textures in game. That's the just of it.
So I am tweening the pegs through the fingerboard because the fingerboard is not perfectly straight (perspective) and scaling the sprites for the peg-things accordingly (because they are GUITextures) Please tell me if I am being unclear with this.
My problem is that I need to implement the scoring system. In a traditional Guitar Hero game, if you hit a button and a peg is not on the button then you lose points and you gain points by hitting the respective button on the guitar for each peg if they are on the button on the screen. My problem is that I do not know how to do this exactly. I need the camera to check if any spawned peg's y value is between two floats in their y position on-screen when a key press occurs.
The problem is, I am using prefabs, so I do not know how to make the camera gather all of the objects that are belonging to the prefab, finding the one in the lead, and then checking it's position and acting accordingly.
That is my question. Sorry if this was too long :) any help is appreciated. Oh and I'm using Javascript for my coding.
Thanks!- YA
Perhaps a screen shot would be helpful, showing how the fingerboard is placed etc.
BU$$anonymous$$P Guys I still need some help here
Answer by fafase · Dec 17, 2011 at 08:06 AM
Here is how I would do it but it might not be the best:
You would have a hitline position that is your hit point, the one at the bottom of the screen. Then you check your prefab position and at the same check which button is hit.
In a way it would go,
If(colorbutton is pressed)
if(distance(prefab, hitline)<range)
point+=score
else point-=score
you can also make it more accurate with more if statement depending on the distance using
if(distance(prefab,hitline)<maxrange && distance(prefab,hitline)>minrange)
this way the closer to the hitline the more point you get.
It might not be the solution but it could be a start.
Good luck
Thank you for the reply. The help is appreciated. Unfortunately, I had already gotten this far before I went to the community for answers. I have the whole system set up much like you have it. $$anonymous$$y issue is that if there are more tan one button of the same color on the scene at once, and I press a button when the first on is on the hit line, I will gain a point, but I will also LOSE a point, because the one behind i also runs the script, hence my problem.
Does anyone have any extremely clever workarounds?
Thanks! - YA
Your answer
Follow this Question
Related Questions
Grab position from instantiated object 1 Answer
Vector3 Transform.Position Not Working 2 Answers
platforme ...HELP!! POSITION ADDING 1 Answer
How do I check if an Object isn't moving? (C#) 1 Answer
Can't move instantiated prefab 2 Answers