I need help with the structure of a game
Hello,
I want to make a car racing game. I have a GameManaker and within him, a GameObject Array of checkpoints and a CarManager Array for a class with a GameObject car within.
Some like this.
class GameManager
GameObject [] checkPoints;
CarManager [] Cars; (into each item, a property with a instance of a car;
and this:
public class CarManager
{
[HideInInspector] public GameObject car;
Any cars can disappear but not your manager.
I tried to follow the structure of the famous tanks tutorial.
My problem is the following: When a car collides with a checkpoint, OnTriggerEnter for this checkpoint launch
void OnTriggerEnter(Collider carCollider)
{
if (other.tag == "Player" && Activated)
{
GMInstance.ActivateNextCheckPoint(gameObject, carCollider.gameObject);
}
}
and call a function in GameManager instance
public static GameManager GMInstance;
to make logic (activate/disable current and next checkpoint and increment chepoint numbers in carManager and other). But I can't identify the car ussing the GameObject got by the collider, beacuse I have the GameObject car not the CarManager father.
I need find or identify the carManager in the array using car GO
It's very har to me, I don't know if it's a correct structure to my game.