- Home /
Help Ship Controll
I Making a pirate game ... and I try to make a script for the ship. But I .. I crash when player to indicate Collider text (for example, "Press E to enter") and when showing the text then the player can press a button and change the camera and enter the steering wheel ship ..and if you press it again the camera switches to the player main camera. Also when I change the player camera continues to move .. I would like a little help here, that when you enter the Collider then show a text .. when I press a button the text gone and the players stop walking around .. and start the ship leads. Please i need help!
This is my script yet:
using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI;
public class ShipCamera: MonoBehaviour {
//public string text;
public GameObject cam1;
public GameObject cam2;
public Text sterText;
bool display = false;
// Use this for initialization
void Start () {
sterText.enabled = false;
cam1.SetActive(true);
cam2.SetActive(false);
GameObject myPlayer = GameObject.FindGameObjectWithTag("Player");
}
void OnTriggerEnter(Collider iCollide)
{
if(iCollide.tag == "Player")
{
display = true;
sterText.enabled = true;
}
}
void OnTriggerExit(Collider uCollide)
{
if(uCollide.tag == "Player")
{
display = false;
sterText.enabled = false;
}
}
void OnGUI()
{
if(display == true) {
if(Input.GetKeyDown(KeyCode.E)) {
cam1.SetActive(false);
cam2.SetActive(true);
sterText.enabled = false;
}
else
{
if(Input.GetKeyDown(KeyCode.E)){
cam1.SetActive(true);
cam2.SetActive(false);
sterText.enabled = true;
}
}
}
if(display == false) {
cam1.SetActive(true);
cam2.SetActive(false);
sterText.enabled = false;
}
}