0
\$\begingroup\$

I'm developing my first Unity game, involving a frog jumping on lilypads. As the frog leaves a lilypad, I would like it to sink beneath the surface. Here's what I have currently, with the lilypads as static tiles:

frog movement

What would be the easiest way to do this? I know how to make an animation, but I'm not sure how to get each LilypadTile to be aware of the player's position, and trigger the animation/state change as the player leaves the LilypadTile. I don't even think Tiles have an Update() function, so am I approaching this correctly? Should I instead make my lilypads be Sprites?

Are there any good written references or example documentation regarding common Unity workflows/organization? I'm tired of watching long YouTube videos for each piece of information I need.

\$\endgroup\$
  • \$\begingroup\$ Have you considered, rather than all lilypads watching the frog's position and updating themselves, instead giving that responsibility to the frog? The frog knows what lilypad it just left, and can instruct the tilemap to swap it for an animated sinking tile. This can be O(1) work done per hop, rather than O(n^2) every frame, where n is the size of your tilemap. \$\endgroup\$ – DMGregory Jul 7 '19 at 17:35
  • \$\begingroup\$ I already solved my problem, but yeah, I guess you're right. Would it be easiest to just put everything in a 2D array with either a pointer to the GameObject at that location or a NULL pointer? I'm new to Unity, so I don't know the best way to access objects from other objects. \$\endgroup\$ – TimD1 Jul 8 '19 at 13:25
  • \$\begingroup\$ If you've solved your problem, please post your solution as an Answer so it can help other developers (and so we can up-vote it!) \$\endgroup\$ – DMGregory Jul 8 '19 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.