Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EnterExit : MonoBehaviour {
- public Transform vehicle;
- public Transform player;
- public Transform exitPoint;
- public Transform doorTriggerLeft;
- public Camera PlayerCamera;
- public Camera CarCamera;
- public bool isPlayerVisible;
- public Component N20;
- public Component Setup;
- public car car;
- public CharacterController adam;
- void Start () {
- }
- void Update () {
- if(Input.GetKeyUp(KeyCode.E) && isPlayerVisible){
- player.gameObject.SetActive(false);
- player.parent = exitPoint.transform;
- player.transform.localPosition = new Vector3(-1.5f,0.0f,0.0f);
- exitPoint.parent = vehicle.transform;
- exitPoint.transform.localPosition = new Vector3(-0.5f,0.0f,0.0f);
- car.enabled = true;
- adam.enabled = false;
- PlayerCamera.enabled = false;
- CarCamera.enabled = true;
- isPlayerVisible = false;
- }
- else{
- if(Input.GetKeyUp(KeyCode.R)){
- //set player invisable
- player.gameObject.SetActive(true);
- //set the exit parent
- player.transform.parent = null;
- //parent player to car;
- exitPoint.parent = vehicle.transform;
- //enable walking
- car.enabled = false;
- adam.enabled = true;
- PlayerCamera.enabled = true;
- CarCamera.enabled = false;
- isPlayerVisible = true;
- }
- }
- }
- void OnTriggerEnter(Collider Player){
- isPlayerVisible = true;
- }
- void OnTriggerExit(Collider Player){
- isPlayerVisible = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement