private void Start() { anim = GetComponent <Animator>(); playerRigidBody = GetComponent <Rigidbody>(); searcher = GetComponent <GameObjectSearcher>(); cameraHolder = transform.Find("Camera Holder"); respawnTimer = respawnTime; healthBarTransform = healthBar.GetComponent <Image>(); meshRenderer = mesh.GetComponent <SkinnedMeshRenderer>(); camera = cameraHolder.GetChild(0).GetComponent <TPCamera>(); ammotext = ammoText.GetComponent <Text>(); ammotext.color = Color.yellow; nameLabel.GetComponent <TextMesh>().text = playerName; nameLabel.GetComponent <TextMesh>().color = new Color(color.r, color.g, color.b); if (isLocalPlayer) { playerCamera.GetComponent <Camera>().enabled = true; nameLabel.GetComponent <TextMesh>().GetComponent <Renderer>().enabled = false; } else { playerCamera.GetComponent <Camera>().enabled = false; } Spawn(); }
public override void OnInspectorGUI() { tpCamera = (TPCamera)target; EditorGUILayout.Space (); if (tpCamera.CameraStateList == null) { GUILayout.EndVertical (); return; } GUILayout.BeginVertical ("Camera State", "window"); EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters.", MessageType.Info); tpCamera.CameraStateList = (TPCameraListData)EditorGUILayout.ObjectField ("CameraState List", tpCamera.CameraStateList, typeof(TPCameraListData), false); GUILayout.BeginHorizontal (); if (GUILayout.Button(new GUIContent("New CameraState"))) { if(tpCamera.CameraStateList.tpCameraStates == null) tpCamera.CameraStateList.tpCameraStates = new List<TPCameraState>(); tpCamera.CameraStateList.tpCameraStates.Add(new TPCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count)); tpCamera.index = tpCamera.CameraStateList.tpCameraStates.Count -1; } if (GUILayout.Button (new GUIContent ("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.index != 0) { tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.index); if (tpCamera.index - 1 >= 0) tpCamera.index--; } GUILayout.EndHorizontal (); if (tpCamera.CameraStateList.tpCameraStates.Count > 0) { tpCamera.index = EditorGUILayout.Popup("State", tpCamera.index, getListName(tpCamera.CameraStateList.tpCameraStates)); StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.index]); } GUILayout.EndVertical (); GUILayout.BeginVertical ("box"); base.OnInspectorGUI (); GUILayout.EndVertical (); EditorGUILayout.Space (); if (GUI.changed) { EditorUtility.SetDirty (tpCamera); EditorUtility.SetDirty (tpCamera.CameraStateList); } }
public void setShutterState(bool isUp) { for (int i = 0; i < m_Cameras.Length; i++) { TPCamera temp = m_Cameras[i] as TPCamera; m_Cameras[i].ShowShutter = isUp; } }
//**********************************************************************************// // INITIAL SETUP // // prepare the initial information for capsule collider, physics materials, etc... // //**********************************************************************************// public void InitialSetup() { animator = GetComponent <Animator>(); tpCamera = TPCamera.instance; hud = HUDController.instance; // create a offset pivot to the character, to align camera position when transition to ragdoll var hips = animator.GetBoneTransform(HumanBodyBones.Hips); offSetPivot = Vector3.Distance(transform.position, hips.position); if (tpCamera != null) { tpCamera.offSetPlayerPivot = offSetPivot; tpCamera.target = transform; } if (hud == null) { Debug.LogWarning("Invector : Missing HUDController, please assign on ThirdPersonController"); } // prevents the collider from slipping on ramps frictionPhysics = new PhysicMaterial(); frictionPhysics.name = "frictionPhysics"; frictionPhysics.staticFriction = 0.6f; frictionPhysics.dynamicFriction = 0.6f; // default physics defaultPhysics = new PhysicMaterial(); defaultPhysics.name = "defaultPhysics"; defaultPhysics.staticFriction = 0f; defaultPhysics.dynamicFriction = 0f; // rigidbody info _rigidbody = GetComponent <Rigidbody>(); // capsule collider capsuleCollider = GetComponent <CapsuleCollider>(); // save your collider preferences colliderCenter = GetComponent <CapsuleCollider>().center; colliderRadius = GetComponent <CapsuleCollider>().radius; colliderHeight = GetComponent <CapsuleCollider>().height; currentHealth = startingHealth; currentStamina = startingStamina; if (hud == null) { return; } hud.damageImage.color = new Color(0f, 0f, 0f, 0f); cameraTransform.SendMessage("Init", SendMessageOptions.DontRequireReceiver); UpdateHUD(); }
// Use this when the object is created void Awake() { //Inicializamos la variable instancia instance = this; DontDestroyOnLoad(gameObject); //Todas las layers seleccionadas excepto UI y Player layerMask = ~((1 << 5) | (1 << 9)); }
// Use this when the object is created void Awake () { //Inicializamos la variable instancia instance = this; DontDestroyOnLoad(gameObject); //Todas las layers seleccionadas excepto UI y Player layerMask = ~((1 << 5) | (1 << 9)) ; }
void OnEnable() { indexSelected = 0; tpCamera = (TPCamera)target; tpCamera.indexLookPoint = 0; if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count > 0) { tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].positionPoint; tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].eulerAngle); } }
void OnSceneGUI() { if (Application.isPlaying) { return; } tpCamera = (TPCamera)target; if (tpCamera.gameObject == Selection.activeGameObject) { if (tpCamera.CameraStateList != null && tpCamera.CameraStateList.tpCameraStates != null && tpCamera.CameraStateList.tpCameraStates.Count > 0) { if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint) { return; } try { for (int i = 0; i < tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count; i++) { if (indexSelected == i) { Handles.color = Color.blue; tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint = tpCamera.transform.position; tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle = tpCamera.transform.eulerAngles; if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[indexSelected].freeRotation) { Handles.SphereCap(0, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle, Quaternion.identity, 0.5f); } else { Handles.DrawLine(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.target.position); } } else if (Handles.Button(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, Quaternion.identity, 0.5f, 0.3f, Handles.SphereCap)) { indexSelected = i; tpCamera.indexLookPoint = i; tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint; tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle); } Handles.color = Color.white; Handles.Label(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].pointName); } } catch { if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1) { tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; } } } } }
// Use this when the object is created private void Awake() { transportando = false; //Inicializamos el componente CharacterController //Inicializamos la variable instancia characterController = GetComponent <CharacterController>(); instance = this; SetState(State.Normal); //creamos o buscamos una camara TPCamera.UseExistingOrCreateMainCamera(); }
//**********************************************************************************// // INITIAL SETUP // // prepare the initial information for capsule collider, physics materials, etc... // //**********************************************************************************// public void InitialSetup() { animator = GetComponent<Animator>(); shootables = new List<Transform>(); // better sync of animations like quickTurn180 animator.updateMode = AnimatorUpdateMode.AnimatePhysics; communication = new SerialCommunication(); tpCamera = TPCamera.instance; CollectShootableBodyParts(transform); if (hud == null) Debug.Log("Missing HUDController, please assign on ThirdPersonController"); // prevents the collider from slipping on ramps frictionPhysics = new PhysicMaterial(); frictionPhysics.name = "frictionPhysics"; frictionPhysics.staticFriction = 0.6f; frictionPhysics.dynamicFriction = 0.6f; // default physics defaultPhysics = new PhysicMaterial(); defaultPhysics.name = "defaultPhysics"; defaultPhysics.staticFriction = 0f; defaultPhysics.dynamicFriction = 0f; // rigidbody info _rigidbody = GetComponent<Rigidbody> (); // capsule collider capsuleCollider = GetComponent<CapsuleCollider>(); // save your collider preferences colliderCenter = GetComponent<CapsuleCollider>().center; colliderRadius = GetComponent<CapsuleCollider>().radius; colliderHeight = GetComponent<CapsuleCollider>().height; CreateBonesToCurve(); currentHealth = startingHealth; currentStamina = startingStamina; if(hud == null) return; hud.damageImage.color = new Color(0f, 0f, 0f, 0f); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Alpha1)) { TPCamera.SetActive(true); MainCamera.SetActive(false); FPCamera.SetActive(false); } else if (Input.GetKey(KeyCode.Alpha2)) { TPCamera.SetActive(false); MainCamera.SetActive(false); FPCamera.SetActive(true); } else if (Input.GetKey(KeyCode.Alpha3)) { TPCamera.SetActive(false); MainCamera.SetActive(true); FPCamera.SetActive(false); } }
void Awake() { m_Players.Add(this); if (i_Character == GameData.Instance.PlayerOneCharacter) { m_Player = Players.PlayerOne; m_PlayerInput = GameData.Instance.m_PlayerOneInput; } else if (i_Character == GameData.Instance.PlayerTwoCharacter) { m_Player = Players.PlayerTwo; m_PlayerInput = GameData.Instance.m_PlayerTwoInput; } else { //error } m_PlayerCamera = transform.parent.GetComponentInChildren <TPCamera>(); }
public void OnDestroy() { if (TargetLookAt != null) { GameObject.Destroy(TargetLookAt.gameObject); TargetLookAt = null; } else { Debug.LogWarning("OnDestroy : TPCamera TargetLookAt"); } if (_instance != null) { GameObject.Destroy(_instance.gameObject); _instance = null; } else { Debug.LogWarning("OnDestroy : TPCamera _instance"); } }
void Awake() { Instance = this; }
//**********************************************************************************// // INITIAL SETUP // // prepare the initial information for capsule collider, physics materials, etc... // //**********************************************************************************// public void InitialSetup() { animator = GetComponent<Animator>(); tpCamera = TPCamera.instance; // create a offset pivot to the character, to align camera position when transition to ragdoll var hips = animator.GetBoneTransform(HumanBodyBones.Hips); offSetPivot = Vector3.Distance(transform.position, hips.position); tpCamera.offSetPlayerPivot = offSetPivot; if (hud == null) Debug.Log("Missing HUDController, please assign on ThirdPersonController"); // prevents the collider from slipping on ramps frictionPhysics = new PhysicMaterial(); frictionPhysics.name = "frictionPhysics"; frictionPhysics.staticFriction = 0.6f; frictionPhysics.dynamicFriction = 0.6f; // default physics defaultPhysics = new PhysicMaterial(); defaultPhysics.name = "defaultPhysics"; defaultPhysics.staticFriction = 0f; defaultPhysics.dynamicFriction = 0f; // rigidbody info _rigidbody = GetComponent<Rigidbody>(); // capsule collider capsuleCollider = GetComponent<CapsuleCollider>(); // save your collider preferences colliderCenter = GetComponent<CapsuleCollider>().center; colliderRadius = GetComponent<CapsuleCollider>().radius; colliderHeight = GetComponent<CapsuleCollider>().height; currentHealth = startingHealth; currentStamina = startingStamina; if (hud == null) return; hud.damageImage.color = new Color(0f, 0f, 0f, 0f); }
public override void OnInspectorGUI() { tpCamera = (TPCamera)target; EditorGUILayout.Space(); if (tpCamera.CameraStateList == null) { GUILayout.EndVertical(); return; } GUILayout.BeginVertical("Camera State", "window"); EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters or scenes", MessageType.Info); tpCamera.CameraStateList = (TPCameraListData)EditorGUILayout.ObjectField("CameraState List", tpCamera.CameraStateList, typeof(TPCameraListData), false); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("New CameraState"))) { if (tpCamera.CameraStateList.tpCameraStates == null) { tpCamera.CameraStateList.tpCameraStates = new List <TPCameraState>(); } tpCamera.CameraStateList.tpCameraStates.Add(new TPCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count)); tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; } if (GUILayout.Button(new GUIContent("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.indexList != 0) { tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.indexList); if (tpCamera.indexList - 1 >= 0) { tpCamera.indexList--; } } GUILayout.EndHorizontal(); if (tpCamera.CameraStateList.tpCameraStates.Count > 0) { tpCamera.indexList = EditorGUILayout.Popup("State", tpCamera.indexList, getListName(tpCamera.CameraStateList.tpCameraStates)); StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList]); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); base.OnInspectorGUI(); GUILayout.EndVertical(); EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(tpCamera); EditorUtility.SetDirty(tpCamera.CameraStateList); } }
public override void OnInspectorGUI() { if (!skin) { skin = Resources.Load("skin") as GUISkin; } GUI.skin = skin; tpCamera = (TPCamera)target; EditorGUILayout.Space(); if (tpCamera.CameraStateList == null) { GUILayout.EndVertical(); return; } GUILayout.BeginVertical("3rd Person Camera", "window"); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (tpCamera.cullingLayer == 0) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Please assign the Culling Layer to 'Default' ", MessageType.Warning); EditorGUILayout.Space(); } EditorGUILayout.HelpBox("The target will be assign automatically to the current Character when start, check the InitialSetup method on the Motor.", MessageType.Info); base.OnInspectorGUI(); GUILayout.EndVertical(); GUILayout.BeginVertical("Camera States", "window"); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters or scenes", MessageType.Info); tpCamera.CameraStateList = (TPCameraListData)EditorGUILayout.ObjectField("CameraState List", tpCamera.CameraStateList, typeof(TPCameraListData), false); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("New CameraState"))) { if (tpCamera.CameraStateList.tpCameraStates == null) { tpCamera.CameraStateList.tpCameraStates = new List <TPCameraState>(); } tpCamera.CameraStateList.tpCameraStates.Add(new TPCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count)); tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; } if (GUILayout.Button(new GUIContent("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.indexList != 0) { tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.indexList); if (tpCamera.indexList - 1 >= 0) { tpCamera.indexList--; } } GUILayout.EndHorizontal(); if (tpCamera.CameraStateList.tpCameraStates.Count > 0) { tpCamera.indexList = EditorGUILayout.Popup("State", tpCamera.indexList, getListName(tpCamera.CameraStateList.tpCameraStates)); StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList]); } GUILayout.EndVertical(); EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(tpCamera); EditorUtility.SetDirty(tpCamera.CameraStateList); } }
private void Start() { mainCam = Camera.main.GetComponent <TPCamera>(); }
// Use this for initialization void Start() { TPCamera.SetActive(true); MainCamera.SetActive(false); FPCamera.SetActive(false); }
void Awake() { CharacterController = GetComponent("CharacterController") as CharacterController; Instance = this; TPCamera.SpawnCamera(); }