Quantcast
Channel: Questions in topic: "vehicles"
Viewing all articles
Browse latest Browse all 123

Enter/Exit Vehicle With UNet

$
0
0
All the topic's I've viewed so far are not what I want. I currently have a good, dependable script for entering and exiting a vehicle in singleplayer, but I'm at a total loss trying to network it. using UnityEngine; using System.Collections; using UnityStandardAssets.Vehicles.Car; using UnityStandardAssets.Characters.FirstPerson; public class GameManager : MonoBehaviour { public Camera playerCam; public FirstPersonController FPSCon; public GameObject Player; public GameObject m_Car; public Transform carParent; bool guiEnable = false; public Camera cam; void Start () { cam.enabled = false; } void Update () { if (Input.GetKeyDown (KeyCode.Escape)) { if (cam.enabled == true) { cam.enabled = false; FPSCon.enabled = true; Player.GetComponent ().enabled = true; playerCam.enabled = true; Player.transform.parent = null; m_Car.gameObject.GetComponent ().enabled = false; } } } void OnTriggerStay (Collider col) { if (col.name == "FPSController") { guiEnable = true; if (Input.GetKey (KeyCode.E)) { if (cam.enabled == false) { cam.enabled = true; FPSCon.enabled = false; Player.GetComponent ().enabled = false; playerCam.enabled = false; guiEnable = false; Player.transform.SetParent (carParent); m_Car.gameObject.GetComponent ().enabled = true; } } } } void OnTriggerExit (Collider col) { if (col.name == "FPSController") { guiEnable = false; } } void OnGUI () { if (guiEnable != false) { GUI.Label (new Rect (Screen.width / 2, Screen.height / 2, 100, 50), "E to Enter."); } else { GUI.Label (new Rect (Screen.width / 2, Screen.height / 2, 50, 50), " "); } } } If anyone can help me out, I would be forever in your debt. Thanks in advance.

Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>