Endless Runner - Spawning sections of ground

I'm creating a side scrolling endless runner game that procedurally generates platforms ahead of the camera.

I'm quite new to coding.

I have the new pieces of road spawning when my player runs into a trigger, but am unsure how to set the position of this newly spawned piece to be right next to the current piece of road.

I've so far managed to trigger the spawning of the next piece of road, but it spawns directly on top of the trigger because I haven't given it additional position information.

My aim is to calculate the edge of the current piece of road and spawn the next piece directly next to it.

I'm also conscious that I will want to have different sized pieces of road to draw from i.e. I can't just input a number as the distance the spawn will be from the trigger will change depending on the piece.

Any help calculating where the edge of my current piece is, and how to position the new piece directly next to it would be greatly appreciated.

Cheers.

Have you worked through the Spawn Shared Asset tutorial? This would be a good place to start.

You will see the use of the {position = ...} option for spawning and whilst the tutorial uses a fixed spacing, you can imagine that by carefully constructing your segment templates and setting a required offset for them as a custom property you should be able to automate variable section sizes.

Be aware of the world size limits Platform Limits and be aware that precision will get reduced before you get to those limits.

Thanks for the response.

I've worked through the spawn shared asset tutorial and found it quite helpful.

I was focussing on trying to calculate the bounds within the script but hadn't considered adding a custom property to each piece with the size. I'll try working that in.

Thanks for the heads up about platform limits, I'll try to keep that in mind.