Around the world

Hi – I am trying to decide how best to add a closed loop feature, like in the old defender when you’d go to the edge of the map and then loop back around. I’d like an object to keep rolling forward, but eventually come back to where it started.

I was initially thinking to just move the camera and object back to the start position, but it looks either too abrupt or appears to lerp in the wrong direction and spoils the illusion.

Another idea would be to just move the entire world to stay always in front of the moving object.

Just wondering what other suggestions folks might have.
Thanks!
Alex

I’m going to duplicate the beginning part of the world at the end, and when it reaches the right point I’ll move the camera and object back to the beginning.

It, of course, always depends on what is in your game and what you are using.
If using tilemaps I have found it nice to to as you say and duplicate the end part and then move the camera.
This must also of course be included in the gameobjects and their logic.
If using physics (especially dynamic) that could cause some problems though.
I have also done the “world moving style” which is really nice in eg Shootemups. Also here dynamic objects could be a problem. Benefits with moving world is that you don’t have to worry about precision errors for the camera, something you will see, especially if using medium precision for position in the shaderprograms.

2 Likes

Thanks for writing!

I am using dynamic physics to animate a rolling ball-- so what I am going to try and do is temporarily disable the collision object and move it and then reapply the force.

What would be neat is if there is some way to make world.X 30000 suddenly equal -30000.

Another option I was thinking of is to make the world itself like a giant octagon and kind of rotate it forward in stages as the ball reaches certain parts so that physics still works. If everything in the world is a child of it, would the rotation only need to be done on the parent? Tt might provide a neat effect with the camera – you can look all around and actually see that the world is “round” but the stage you are currently in is at the top.

Given that Defold is 3D, I’d try making the game in polar coordinates. The game level would be a cylinder with a camera inside it. Game objects would be flat quads slightly closer to the camera not to cause any occlusion by the terrain and always being normal to the camera view vector.

2 Likes

Thank you for your suggestion - it sounds cool. I have to admit I don’t completely understand it, but I will try to.

What do you mean by polar coordinates?

Usually you have x, y, z. But in this case you would operate with radius (distance from the center axis of the cylinder), height (along the axis) and angle (from 0 to 2*pi on the surface of the cylinder). Of course you would need to constantly convert these coordinates to the proper x,y,z for rendering.

2 Likes

Will have to think about this one – thanks again for the suggestion though!