Search Unity

Is it good to cut a long track in pieces?

Discussion in 'Scripting' started by Bongmo, Dec 29, 2017.

  1. Bongmo

    Bongmo

    Joined:
    Jan 18, 2014
    Posts:
    155
    Hi.

    I'm making a mobile car game. In the game there is a very long track. I made it with blender.

    When you play the game it takes about two minutes to finish the track.

    Now to my question.

    - Is it better to cut the whole track in pieces. Then in the game the first track part is visible with SetActive(true).
    When the player comes to the next part of the track, I set the next track piece like SetActive(true); and so on.

    - Or is it better to Instantiate the track parts? E.g. The first track part is visible. When the player comes to the next track part I instantiated the next part and destroy the previous part.

    - Or is it better with only one long track, because the player don't sees the whole long track. So the camera just displays the actual player position.

    What is the best solution for this?

    Thanks in advance.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Why are you guessing? Use the profiler. There are no answers to your question that remain the same answers for everyone.

    This is WHY there is a profiler.
     
    Ryiah and Joe-Censored like this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The answer can depend on what hardware platform you are targeting, if you are using different LOD's for your track pieces, how complex your models are, etc. As already mentioned, trying several options and using the profiler is the only real answer.

    I'm going to make a guess that in general the instantiate/destroy track idea isn't going to perform as well as enabling/disabling since instantiate/destroy has more processing overhead.
     
    Bongmo and Ryiah like this.