Answer the question
In order to leave comments, you need to log in
When an object spawns, it is not visible in the game, but it is on the stage. What's the catch?
When I just drag an object onto the stage, everything is fine, when I try using Instantiate, it is not visible in the game (the object is on layer 100, other objects are -1 - 5). What is the problem?
The code:
private void OnTriggerExit2D(Collider2D collision)
{
if(collision.CompareTag("Road"))
{
OldRoad = collision.gameObject;
GameObject road = Instantiate(RoadPrefab, collision.transform.parent.position + RoadOffset, Quaternion.identity);
CarOffset.x = Random.Range(-2f, 2f);
CarOffset.y = Random.Range(-2f, 2f);
Instantiate(CarPrefab, road.transform.Find("GameObject").position + CarOffset, Quaternion.Euler(0,0,180));
Invoke("DeleteRoad", 3f);
}
}
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