Advertisement
Guest User

Untitled

a guest
May 16th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2. public class EnterExit : MonoBehaviour {
  3.  
  4. public Transform vehicle;
  5. public Transform player;
  6. public Transform exitPoint;
  7. public Transform doorTriggerLeft;
  8. public Camera PlayerCamera;
  9. public Camera CarCamera;
  10. public bool isPlayerVisible;
  11. public Component N20;
  12. public Component Setup;
  13. public car car;
  14. public CharacterController adam;
  15.  
  16.  
  17.  
  18. void Start () {
  19.  
  20. }
  21.  
  22.  
  23. void Update () {
  24. if(Input.GetKeyUp(KeyCode.E) && isPlayerVisible){
  25.  
  26. player.gameObject.SetActive(false);
  27.  
  28. player.parent = exitPoint.transform;
  29. player.transform.localPosition = new Vector3(-1.5f,0.0f,0.0f);
  30.  
  31. exitPoint.parent = vehicle.transform;
  32. exitPoint.transform.localPosition = new Vector3(-0.5f,0.0f,0.0f);
  33.  
  34. car.enabled = true;
  35. adam.enabled = false;
  36.  
  37. PlayerCamera.enabled = false;
  38. CarCamera.enabled = true;
  39. isPlayerVisible = false;
  40. }
  41. else{
  42. if(Input.GetKeyUp(KeyCode.R)){
  43. //set player invisable
  44. player.gameObject.SetActive(true);
  45. //set the exit parent
  46. player.transform.parent = null;
  47. //parent player to car;
  48. exitPoint.parent = vehicle.transform;
  49. //enable walking
  50. car.enabled = false;
  51. adam.enabled = true;
  52.  
  53. PlayerCamera.enabled = true;
  54. CarCamera.enabled = false;
  55. isPlayerVisible = true;
  56. }
  57. }
  58. }
  59. void OnTriggerEnter(Collider Player){
  60. isPlayerVisible = true;
  61. }
  62.  
  63. void OnTriggerExit(Collider Player){
  64. isPlayerVisible = false;
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement