49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
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<CapsuleCollider>().enabled = false;
|
|
LiveSceneManager.Instance.firstPersonController.GetComponent<Rigidbody>().useGravity = false;
|
|
LiveSceneManager.Instance.firstPersonController.GetComponent<Rigidbody>().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<CapsuleCollider>().enabled = true;
|
|
LiveSceneManager.Instance.firstPersonController.GetComponent<Rigidbody>().useGravity = true;
|
|
LiveSceneManager.Instance.firstPersonController.playerCanMove = true;
|
|
SmallMap.SetActive(false);
|
|
}
|
|
OnCar = !OnCar;
|
|
}
|
|
|
|
}
|
|
}
|