Hello. I am working on a "runner" type game (like canabalt) and I am wondering how to spawn the level sections. I currently just spawn a bunch of sections, that are all the same size in a line. This allows for some design changes, but I want to spawn objects that are different sizes. I have an idea, but I am not sure how to do it.
Rather than instantiating based on the origins of the two objects (the one that is doing the instantiating and the one that is being instantiated), I want to find the end points of the objects, and then have the spawns be based off of those endpoints. My thought was to attatched this code to a level section, and a second or so after it has been spawned, invoke the institute function (but to avoid getting an infinite amount of objects at one time, I would just destroy the section after the player runs by it or set a cap on the amount of sections that can be spawned at one time or something like that,). Basically, I want to turn the ends of objects into their origins (without actually changing the object) How would I do that?
Thanks
Bounds is of course a solution but keep in mind that bounds always represents the AABB (axis aligned bounding box) which can be bigger than the actual object, especially when your objects are not world axis aligned. But in most cases that's the easiest,automatic solution ;)
– Bunny83You could move it to the bounding edge of the most recently spawned object and then move it a little bit more based on the next objects bounding value. It may take some fiddling to get just right, especially if you applying rotations as you go.
– anon69682588