- Home /
2D Ground, really long, how?
What's the best way to make a really long ground in a 2D game? I mean, massively long, like 20, 40 or even 100 screen widths long.
Needs physics. Has a tiling texture.
Answer by Stratosome · Jul 23, 2018 at 07:10 AM
Well, there are a couple ways you could do it. Just make 1 platform and set its width to your large value to be as big as you want. Or you could place a bunch smaller ones yourself. Or even you could generate the platforms as you move along the path. I'd say if there are any "cutscene" like things, breaks in the gameplay, or something like that, I'd say break it up. If you do it with code, it could be an easily adjustable length to perhaps just keep adding platforms the further you go, so it would automatically stop whenever you decide to have the player finish the level or end the game or whatever.
I think figuring out the best approach to it would depend on the type of game that you are trying to make. If there are repeated areas on the level, I'd say break it up into chunks and spawn them in. If every part of it is unique, maybe just making a really long collider would be fine.
I kind of need a really long collider (and graphic) for some weird, pseudo 3D shots of the level, during fast parts in the action and rapid level previews right at the start of each level, that also peer down the length of the levels before straightening up and scrolling across.
Are there any negatives to having a huge object of enormous length? eg do iOS or Android phones go bezerk if something is super long?
Ooo, that sounds cool. In that case, yeah, a long platform ins$$anonymous$$d of breaking it up into parts I think would be the way to go (they would just be really looong parts) (or I guess you could break it into parts and generate the whole thing right at the start? that would be a decent option if it isn't just one long straight platform). Um, sadly, I'm not really certain about any possible issues it would cause to do that? I guess I've just never done that and put it into some project before (especially not mobile stuff). But I'd be willing to bet that it would be totally fine. Having a single long collider would probably be more efficient than a bunch of smaller ones actually.
I would probably break it up into smaller chunks so that the ones which are off-screen don't need to be considered for the physics collisions.
Oh, yeah, I suppose that's a good point too. Forgot about that hah.
plus you can then use occlusion culling and the device won't have to render all those pieces
Your answer
Follow this Question
Related Questions
Colliders 2d apparently touch each other even if they should not. 2 Answers
Question about Scripting a slingshot mechanic 0 Answers
Set targetjoint2d anchor position at mouse position in 2d 0 Answers
Velocity from external objects 0 Answers
Jitter/vibration on an object with constant velocity when using 2D Pixel Perfect Camera 1 Answer