Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityStandardAssets.Vehicles.Car;
- public class carManager : MonoBehaviour
- {
- public Camera carCam;
- public CarUserControl userCtrl;
- public GameObject VladInsideCar;
- public GameObject GabrielaInsideCar;
- public GameObject AlinInsideCar;
- private bool inVeh;
- private GameObject player;
- void Start()
- {
- userCtrl.enabled = false;
- carCam.enabled = false;
- VladInsideCar.SetActive(false);
- GabrielaInsideCar.SetActive(false);
- AlinInsideCar.SetActive(false);
- inVeh = false;
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.F))
- {
- if (inVeh == true)
- {
- VehicleControl(null);
- }
- }
- }
- public void VehicleControl(GameObject playerObj)
- {
- if (inVeh == false)
- {
- if (playerObj.tag == "Vlad")
- {
- player = playerObj;
- carCam.enabled = true;
- userCtrl.enabled = true;
- VladInsideCar.SetActive(true);
- player.SetActive(false);
- player.transform.parent = this.transform;
- StartCoroutine(Time(true));
- }
- else
- if (playerObj.tag == "Gabriela")
- {
- player = playerObj;
- carCam.enabled = true;
- userCtrl.enabled = true;
- GabrielaInsideCar.SetActive(true);
- player.SetActive(false);
- player.transform.parent = this.transform;
- StartCoroutine(Time(true));
- }
- else
- if (playerObj.tag == "Alin")
- {
- player = playerObj;
- carCam.enabled = true;
- userCtrl.enabled = true;
- AlinInsideCar.SetActive(true);
- player.SetActive(false);
- player.transform.parent = this.transform;
- StartCoroutine(Time(true));
- }
- }
- else
- {
- player.SetActive(true);
- carCam.enabled = false;
- VladInsideCar.SetActive(false);
- GabrielaInsideCar.SetActive(false);
- AlinInsideCar.SetActive(false);
- userCtrl.enabled = false;
- player.transform.parent = null;
- player = null;
- StartCoroutine(Time(false));
- }
- }
- private IEnumerator Time(bool inVehicle)
- {
- yield return new WaitForSeconds(1);
- inVeh = inVehicle;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement