protected virtual void Awake() { Instance = this; // Instantiate controller prefab if (Controller == null) { GameObject go = Instantiate(BodyPrefab, Vector3.zero, Quaternion.identity) as GameObject; Controller = go.GetComponent <VZController>(); Controller.transform.localScale = Vector3.one; Controller.name = "VZController"; DontDestroyOnLoad(Controller); } // Reparent it to us Controller.transform.SetParent(transform, false); // Raycast mask mRaycastMask = ~(LayerMask.GetMask("VZPlayerCollider") | LayerMask.GetMask("Ignore Raycast") | LayerMask.GetMask("VZObjectCollider")); #if VZ_PLAYMAKER // Cache PlayMaker FSM variable references. mPlayMakerVariables.Init(); #endif }
// Initialization void Start() { controller = VZPlayer.Controller; path = Application.persistentDataPath + "/"; FHIRHUD = GetComponentInChildren <TextMesh>(); FHIRHUD.text = ""; }
protected virtual void OnDestroy() { // Reset globals for next play mode if (mIsQuitting) { Destroy(Controller); Controller = null; sFirstTime = true; } // Else unparent shared model and destroy hud we gave it else { Controller.transform.SetParent(null, false); } }
protected virtual void OnDestroy() { // Reset globals for next play mode if (mIsQuitting) { Destroy(Controller); Controller = null; sFirstTime = true; } // Else unparent controller model else { Controller.AttachPlayer(null); Destroy(Camera.gameObject); if (HUD != null) { Destroy(HUD); } } }
protected virtual void Awake() { Instance = this; // Init camera if (Camera == null) { Camera = UnityEngine.Camera.main.transform; } Camera.transform.localPosition = Vector3.zero; Camera.transform.localRotation = Quaternion.identity; // If no rigidbody make one if (GetComponent <Rigidbody>() == null) { gameObject.AddComponent <Rigidbody>(); } // Instantiate controller prefab if (Controller == null) { GameObject go = Instantiate(BodyPrefab, Vector3.zero, Quaternion.identity) as GameObject; Controller = go.GetComponent <VZController>(); Controller.transform.localScale = Vector3.one; Controller.name = "VZController"; DontDestroyOnLoad(Controller); } // Attach controller to us Controller.AttachPlayer(this); // Raycast mask mRaycastMask = ~(LayerMask.GetMask("VZPlayerCollider") | LayerMask.GetMask("Ignore Raycast") | LayerMask.GetMask("VZObjectCollider") | LayerMask.GetMask("UI")); #if VZ_PLAYMAKER // Cache PlayMaker FSM variable references. mPlayMakerVariables.Init(); #endif }