Unity2D game infinite refresh map

Hits: 0

How to refresh the map infinitely in Unity2D games
First, create multiple objects of the same size as refreshed map objects in Unity, then create a script named Endless.cs, and then add the following code

public float distance;
    void OnBecameInvisible(){
        transform.Translate(Vector3.right* distance * 3);
};

Add the script to the object that needs to be refreshed, and set the value of distance in the editor. The value of distance refers to the difference of X between the two objects.
Because the principle of this infinite refresh is that when the camera obtains the currently seen object and does not obtain the seen object to refresh to the next position, the Scene view needs to be closed.

You may also like...

Leave a Reply

Your email address will not be published.