- Home /
Generate a continuos platform for endless runner
Hey Guys! I'm trying to make a 3d side scrolling endless runner for mobile platforms. My player is going to run on a street. So, I've just created a street prefab and I want to instantiate it continuously as the player moves to the right.
But I don't exactly know how to instantiate it in a continuos manner so that the player doesn't falloff through the gaps in the street. How to get the exact point where to generate the next street prefab?
I'm new to unity. So please bear with me. Any help is much appreciated. Thank you
Answer by instruct9r · Mar 31, 2014 at 12:19 PM
What i woud do is this: Get the length of each piece of street, that will be instantiated. I guess they are more than 1 and i guess they are different size, so take each one's length and when instantiating the next one, just add it to the position of the previous one + it's length. How to instantiate it at the right moment, i woud use a trigger somewhere at the middle of the current platform, so when the player touches it, the next one get's instantiated. You can also use the same trigger to deactivate the previous one, so you don't have ton's of objects behind...
Answer by trololo · Mar 31, 2014 at 12:34 PM
You could use a raycast on each side of your screen (to know when you have to duplicate/translate your scene), but the whole thing is gonna be much difficult if you want to do a parallax scrolling system.
Answer by NDJoshi · Mar 31, 2014 at 01:22 PM
If you are new to unity, i would advice you to move you tract towards the character insipite moving your character. It will get very simple for you. For that you just have to take a plane or a quad, put on your texture(repeat mode). And put on below script on your surface object, and it will run towards your character. renderer.material.mainTextureOffset = new Vector2 (Time.time * speed, 0f);