private void Awake() { carSelected = PlayerPrefs.GetString("carSelected", "Derby"); DontDestroyOnLoad(this); if (carSelectedObject == null) { carSelectedObject = this; } else { Destroy(gameObject); } }
public void SelectObject(GameObject gameObject) { SelectedCar = gameObject; SelectedCar.SetActive(true); Vector3 camForward = Camera.main.transform.forward; camForward = new Vector3(camForward.x, 0, camForward.z).normalized; Quaternion carRot = Quaternion.LookRotation(-camForward); SelectedCar.transform.rotation = carRot; CarSelected?.Invoke(gameObject); }
private void Awake() { _carSelected = FindObjectOfType <CarSelected>(); }