Exemplo n.º 1
0
    public void Init(CarAIData data)
    {
        Data = data;

        if (Data.Keys.Count > 0)
        {
            SimpleCarController prefab = LevelManager.Instance.GetCarsList()[Data.CarIndex];
            CarController = Instantiate(prefab);
            CarController.transform.SetParent(transform);
            CarController.Init(CarOwner.kAI);
            if (Data.Keys.Count > 1)
            {
                Vector3 spawnLocation = Data.GetKey(0);
                Vector3 targetVector  = Data.GetKey(1) - Data.GetKey(0);
                CarController.SetTransform(spawnLocation, Mathf.Atan2(targetVector.x, targetVector.z) * Mathf.Rad2Deg);
                CanMove        = true;
                TargetKeyIndex = 1;
            }
        }
    }