Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Infinite Runner effeciency

Discussion in 'Scripting' started by vuyiswamb, Jul 9, 2015.

  1. vuyiswamb

    vuyiswamb

    Joined:
    Apr 30, 2014
    Posts:
    12
    Good Day

    i have been following Unity Live tutorials and also checked the archives and looked others in you-tube. I m interested in infinite Runner type of game. i looked at the examples and i see they create the environment for the character on-fly during the game. in all examples i see that the things like obstacles get created and a trigger is created to dispose them. also the environment gets created as the character runs. i also saw another approach which i doubted if it was efficient. The demonstration actually created the ground that looks like its moving at a certain speed and the third-person controller had to look like he is running and the obstacles are spawn into the game dynamically. i saw the hierarchy window generating lots of objects. i checked the task manager to check how quickly the resources are consumed. it was not that bad but i am just thinking with assets that are complex not made from a cube how will this go expansive.

    So my Question is , what is the efficient way to create an infinity Runny game?
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    Both approaches are equally valid, and will work.

    For the case where you're moving the the obstacles and background, but keeping the player still, you're moving more objects than you would in the case where you move the character, so it might be a bit more resource intensive. That being said, your obstacles should be simple shapes - cubes in 3D, simple polygons and boxes in 2D - so it shouldn't be a problem.

    Do whatever you think it'd be the easiest to code.
     
  3. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    A good solution is pooling for this, if you are creating and killing lots of objects that will cause the garbage collector to kick in pretty hard core and cause the game to stutter. So instead using existing objects and keep moving up infront of the player.

    Also instead of moving the world around the player i was successful and moving the player, and having everything warp back to 0 0 0 once you get too far away from the world origin for floating point accuracy to be a problem
     
  4. vuyiswamb

    vuyiswamb

    Joined:
    Apr 30, 2014
    Posts:
    12
    Good Day

    Thank you for the advice , it is valuable