How do you make behaviours apply to nearest actor first? (Guitar Hero game)
Hey guys. Ive got a few projects on the go at the moment, including a Guitar Hero style game. The problem im having at the moment is that i want the closet actor to you to be the target. let me explain:
Say i have 2 buttons; Red button and Green button.
when a red target appears, you press the red button to destroy it.when a green target appears, you press the green button to destroy it. But if both the red AND the green target are on the screen at the same time, i want whichever button you press to apply to the nearest actor. So if the red target spawns, then the green one behind it, i want the buttons to affect the red target first, and ignore the green until the red has either been destroyed or has gone past you. If you press the red button, you destroy it, If you press the green button for the red target, you lose a life. Does that make sense? Anyone got any ideas? Cheers
Comments
Here's what I came up with. It's a start at least. When you click anywhere, the lowest actor is destroyed.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
wow @tatiang thanks a lot for putting that together! Its definitely a great framework for me to build around and tweak. This is almost exactly what i was looking for! Cheers
You're welcome. Someone else might have a better way but I considered checking the y positions of the actors, their self.Time, and ultimately just keeping track of their spawn order which seemed best.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User