I’m still quite new to unity and I’ve been working on a 2d game as a way to help me learn. In my game the lobster character simply moves left and right and as those blue pearls drop you have to grab them to score points.
I’d just like to know if you guys can show or tell me a simple way to allow those pearls to generate randomly and drop from the top to bottom and then collide with the lobsters claw if the player closes her claw in time.
I’ve included a screen shot so you have a better idea of what I mean.
The logic of this game is very similar to the Unity 2D demo…
In that demo, the aliens generate randomly and drop from the sky. So those are like your pearls.
Then for detecting if the claw is closed on a pearl, first detect collision in the same way that the demo detects collision between the aliens and the main player. Once you detect collision, then check what the angle of rotation of the claw is in order to determine if the claw is closed. Then check the position of the pearl in relation to the position of the pearl to determine if the pearl is inside the closed claw, or if the pearl is touching the outside of the closed claw. Alternatively put a trigger inside the claw to detect if the pearl touched the inside of the claw.