- Home /
Design/discussion question
Swapping sprites after time passes. Animate? Swap? How?
I am working on a 2D top down farming game similar to Harvest Moon (I know. Another one).
I am pretty new to C# and Unity in general. My current issue is that once I figure out how to get my character to plant a crop tile, how do I change the crop tile to show as planted? Do I swap the sprites somehow? Is that done by replacing the sprite with a single frame animation once the condition has been met? Seems to me that would be a waste of processor power. Is there a way to swap the sprites via a C# script?
Anyone who can help out?
Once I have this figured out, I can just set a rate at which the sprite accrues growth and have the sprite change to the next stage of growth until it hits maturity.
This open-ended question is best suited to the forums.
You really need a robust custom-built sprite drawing solution for a game with the mechanics you're describing.
You should build your world around a modular tile-based system which encompasses collision (walkability), effects (water tiles create splash particles when entered), and entities. Each tile's uvs should be able to change - based on their type and state - to draw a different part of a sprite atlas.
Plants and other objects should be distinct entities which draw "on top of" the underlying tile. Each entity can have its own script which helps track its state (like plant maturity), and use the same UV-swapping method to pick the appropriate cell of a texture atlas for drawing.
Follow this Question
Related Questions
Rotating a sprite distorts it? 0 Answers
Pixel-perfect custom sprite pivot point 2 Answers
SpriteRenderer change order in layer in edit mod via script 1 Answer
Custom 2D armor slots 1 Answer