Home Unreal Engine

Procedural race track environment (UNREAL)

I am working on something a bit similar to roadrash but with the car and endless like subway surfer or other similar 2d race game. Now I have completed car mechanics the way I want it in the game. Now, I am clueless about how can I make the buildings spawn (have created 14 variations of the building as of now) next to the track. 
Note- I am keeping the car move forward as in-place mechanics was not really coming along as I wanted.

Please let me know if there's a way to spawn random buildings that will be selected from the set of assets.

Thank you :)

Replies

  • poopipe
    Offline / Send Message
    poopipe polycount lvl 666
    Yes,
    you can set a variable of any type to be an array on a blueprint.

    Do that with static meshes, add all your buildings to the array and select a random index from it to spawn a new static mesh component

  • privateunlimited
  • privateunlimited
    poopipe said:
    Yes,
    you can set a variable of any type to be an array on a blueprint.

    Do that with static meshes, add all your buildings to the array and select a random index from it to spawn a new static mesh component

    Thank you for responding and for boiling it down for me. 
    I have 1-2 more doubts, 2 buildings have different width so as to avoid any clipping should I omit those or how I can imagine doing this after reading your reply is to create two different arrays, one with buildings of the same width and the other with a different width than rest. Now, I am not sure how to spawn these randomly without spawning two at the same location. Also, I was thinking of putting some roads at random locations so the world won't feel monotonous but I will try to keep the width of the road similar to that of majority of buildings.
    Please let me know how I can achieve these smartly.
    I really appreciate this gesture of helping, thank you so much. You are awesome.
  • poopipe
    Offline / Send Message
    poopipe polycount lvl 666
    Usually for this sort of stuff you'll work on a grid based system, testing only against nearby buildings rather than all buildings. 

    The algorithm you want depends how irregular you want the layout to be. 
     For something irregular look at circle packing or Poisson distribution algorithms.  For more regular (grid based) layouts  the logic is a lot simpler and Ive never bothered to look up an algorithm

    As far as working out building sizes goes you can get the bounding box size for a static mesh in your blueprint 

    Practically speaking though, you'll probably get away with just laying them out on a grid, buildings usually have regular road sized gaps between them anyway
  • privateunlimited
    poopipe said:
    Usually for this sort of stuff you'll work on a grid based system, testing only against nearby buildings rather than all buildings. 

    The algorithm you want depends how irregular you want the layout to be. 
     For something irregular look at circle packing or Poisson distribution algorithms.  For more regular (grid based) layouts  the logic is a lot simpler and Ive never bothered to look up an algorithm

    As far as working out building sizes goes you can get the bounding box size for a static mesh in your blueprint 

    Practically speaking though, you'll probably get away with just laying them out on a grid, buildings usually have regular road sized gaps between them anyway
    Thank you buddy this really gave me a base to start with and I have achieved some results too using this, this was helpful. Thank you :)
Sign In or Register to comment.