Answer the question
In order to leave comments, you need to log in
How to generate an object in such a way that when it appears it will be rotated to the left / right side?
In the context of generation, we are talking about an endless runner like Subway Surfers or Temple Run. There are three different parts of the road (already with pickups and obstacles), but they are created one after the other. The idea is to create turns, that is, so that the player understands that the created object indicates a left turn. When planning mentally, the question immediately arises of how to prevent these turns from leading the player to the beginning of the map. Indeed, in random generation, such an option is also possible.
void Awake()
{
GameObject curRoot = RoadRoot;
roadPos = new Vector3(0, 0.5f, (curRoot.transform.position.z - 100));
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Spawner")
{
GameObject newRoad = GameObject.Instantiate(RoadSpawn[Random.Range(0, 3)], roadPos, Quaternion.identity);
roadPos.z = newRoad.transform.position.z - 100;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question