Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to make crops mature over time like in Stardew Valley?

SentokooSentokoo Member
edited October 2020 in Programming

Hey gang,

What's the easiest way to make crops that mature after a set amount of time in Unity / C#? I want to plant a seed and then have it transform into a tiny plant, then a full-grown plant which can be harvested.

I've tried to make one prefab instantiate another and then destroy itself, but that doesn't seem to be working. And it's hard to assign position and rotation that way.

I'm guessing there is probably an easier way to just transform/swap one prefab into another, in the same location, once a set amount of time has passed??

Answers

  • HNJHNJ Member
    edited October 2020
    Vector3 oldPos = transform.position;  //Transform of the old prefab
    
    transform.position = oldPos; //Here, Transform of the new Prefab
    

    Similarly, you can get rotation

Sign In or Register to comment.