-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnterVehicleShip.cs
More file actions
55 lines (51 loc) · 1.44 KB
/
EnterVehicleShip.cs
File metadata and controls
55 lines (51 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using UnityEngine;
using System.Collections;
public class EnterVehicleShip : MonoBehaviour
{
private bool inVehicle = false;
ShipController vehicleScript;
public GameObject guiObj;
GameObject player;
public GameObject camera;
void Start()
{
vehicleScript = GetComponent<ShipController>();
player = GameObject.FindWithTag("Player");
guiObj.SetActive(false);
}
// Update is called once per frame
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player" && inVehicle == false)
{
guiObj.SetActive(true);
if (Input.GetKey(KeyCode.E))
{
guiObj.SetActive(false);
camera.SetActive(true);
player.transform.parent = gameObject.transform;
vehicleScript.enabled = true;
player.SetActive(false);
inVehicle = true;
}
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
guiObj.SetActive(false);
}
}
void Update()
{
if (inVehicle == true && Input.GetKey(KeyCode.F))
{
vehicleScript.enabled = false;
camera.SetActive(false);
player.SetActive(true);
player.transform.parent = null;
inVehicle = false;
}
}
}