Hi, I want to do an endless game for android but I don’t know how to do it. I read some posts and they are talking about to move the scene and animate the character in the same place. But here is my problem… I don’t get it… How could I create an endless game in runtime an move it with the roads and enemies and blockers… Can anyone give me an idea? Thanks!
Please anyone?
I’m not sure how to set a tile behind the another one. Do I have to use FixedJoint?
If I move manually each tile I have to reference the player to each tile to know what is the velocity… is that right? And with float points I will see a white space between them.
Can anyone help me?
Lets say your endless game has level parts, maybe think of real stairs(the things you have to walk up inside buildings), once you step onto a stair another one after it is there. Thats what you want to do. You want to make sure that when a section of your game is finished there is another one in front of it.
example: 3 sections. Your playercharacter always runs in one direction by itself. player can only jump or attack
section1 is a road where you have to jump because theres a hole or obstacle
section2 is just platforms where you have to jump from one to another
section3 is filled with some enemies where you have to evade by jump or attack them
now you instantiate 2 of each sections (2x section1, 2x section2, etc.)
whenever you reach a certain point(maybe through collider OnTriggerEnter or distance checks) in the section your character is currently in you have to make sure to place another section at the end of the current section. Once your character enters the next section you need to reset the one he was in previously. Reset means you have to turn its values back to default(same as when the player entered it).
Thats how it works. The problem is that you need to make sure that the sections appear at the right time in a way the player doesnt mention them to pop out of nothing. In sidescrollers thats simple. In 3d games that might be problematic as you always have to make sure that the player won’t realise that the sections are the appearing out of nowhere
Thank you… I understood that part… I instantiate differetents parts and then I will use it again when they are out of screen.
So, I don’t move my player character I move the world. When I create the first part I’ll link it to the player to know the velocity and move it to that direction. Right?
My doubt is the following:
|part1| |part2| (Two parts moving)
|
|->My problem is this space because of floating points. Not always will be prefectly fixed I will see a white space right?
I don’t get how to create a lot of parts and move them toghether. Can you help me?
Thanks
you only move the character. not the world.
If you make your world meshes with sizes that dont require floating point numbers you wont have any trouble at all. so if x value of section1 is exactly 20units long, there wont be any precision problems. Just make sure to work out accurate mesh dimensions
But in an endless world position values going to be infinit… Unity doesn’t have problem with this?
So you mean something like Temple Run? Your best bet would be to have pre-made “tiles” stored into prefabs and instantiate them randomly.
P.S. I noticed you are Greek and I am Greek, as well so if you at some point need any help do not hesitate to send me a PM. ![]()
I think you’re better of moving the world if the camera is going to be centered on the player, mate…
Dispose or reuse the instances when they get out of screen, and when you instantiate, use integer-like coordinates.
Thanks! But I’m not greek… I only a fan of the greek culture.
EvansGreen… I don’t understand what you mean with integer-like coordinate.
If I have te last instance in position 4.333345621 because it is moving… I have to instantiate the next in 4.4 and there will a white space between them… it will not be perfect fix. How could I fix this?
Hi Guys…i want to create an endless racing track…i m using a racing track how can i repeat this track again and again so it seems an endless road…plz help me…
If I have the last instance in position 4.333345621 because it is moving… I have to instantiate the next in 4.4 and there will a white space between them… it will not be perfect fix. How could I fix this?
That’s exactly what evans wanted to reference to.
It’s much easier to achieve if you build tiles that consist of whole or easily divisable sizes. an integer is a full number (1, 2, 3, etc. but not 1.1, 1.2) btw
If your character would “walk on top of tiles with a size of 1 by 1 by 1”, it would be much easier to guess when this tile should spawn to be in the correct position, wouldn’t it?
also, try taking a look at this tutorial (Runner, a Unity C# Tutorial ) it’s intended for c#, but if youre using java you can still use the theory to base your script on nevertheless ofcourse. ![]()
the easy method is in a rundown:
-define your “tile size” of the parts you build up your level in.
-define the total size of “the visible world”
in example if you make parts that all consist of 3x3x1 (x,y,z) and are looking at the x-y plane mainly (direction parallel to z):
If there would fit a total of 8 “tiles” in the screen:
- On begin of the level:
generate 8 random tiles
set player position to about 1/3rd of the screen( 8 tiles times 3 (which is tilesize on x axis) is 24 world units total in view from left to right, 1/3rd of 24 is 8. so the player would be at a relative position of 8.)
one piece is “3 units long” basically. so for every 3 worldunits the player “travelled” when starting the game in this example repeat these steps:
remove the most left tile, add a whole new tile at the end (should be approximately 16 world units away)
however for destruction you can in example also use raycasting to have all the objects on the left of your player (in the case of my example) destroyed.
do you understand the gist?
I don’t get it at all. I understand move the character 1 by 1 to get it easier. But… I have the character attached in all the tiles as the observed to know the velocity. So, the velocity of the character have to be incremented by 1.
In the update of the tiles I have to translate them by the character velocity multiplied by the deltaTime. And that gives the float point.
I just released the Endless Universe package on the Asset Store. It works by setting up object-spawning nodes around your player. The array storing the presence of objects shifts when you move a certain distance in a certain direction it generates a new row of objects.