using System.Collections; using System.Collections.Generic; using UnityEngine; public class GetOnCar : MonoBehaviour { public GameObject getOnPoint; public GameObject getOffPoint; public GameObject SmallMap; protected bool OnCar = false; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.F)) { if (!OnCar) { LiveSceneManager.Instance.firstPersonController.GetComponent().enabled = false; LiveSceneManager.Instance.firstPersonController.GetComponent().useGravity = false; LiveSceneManager.Instance.firstPersonController.GetComponent().velocity = Vector3.zero; LiveSceneManager.Instance.firstPersonController.transform.SetParent(getOnPoint.transform); LiveSceneManager.Instance.firstPersonController.transform.localPosition = Vector3.zero; LiveSceneManager.Instance.firstPersonController.transform.localRotation = Quaternion.identity; LiveSceneManager.Instance.firstPersonController.playerCanMove = false; SmallMap.SetActive(true); } else { LiveSceneManager.Instance.firstPersonController.transform.SetParent(null); LiveSceneManager.Instance.firstPersonController.transform.localPosition = getOffPoint.transform.localPosition; LiveSceneManager.Instance.firstPersonController.GetComponent().enabled = true; LiveSceneManager.Instance.firstPersonController.GetComponent().useGravity = true; LiveSceneManager.Instance.firstPersonController.playerCanMove = true; SmallMap.SetActive(false); } OnCar = !OnCar; } } }