// Update is called once per frame void Update() { if (player == null) { player = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterController>(); } if (main == null) { main = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); mainFollow = main.GetComponent <FollowGameObject>(); } else if (mainFollow.targetObjectTransform == null && player != null) { if (player.pawn != null) { mainFollow.targetObjectTransform = player.pawn.tf; } } //Check for win if (playerScore >= winCondition) { GameObject.FindGameObjectWithTag("SceneChanger").GetComponent <SceneChanger>().RunWin(); } }
// Use this for initialization void Start() { cameraMain = GameObject.FindGameObjectWithTag (Tags.mainCamera); smoothCam = cameraMain.GetComponent<SmoothCamera2D> (); playerTransform = GameObject.FindGameObjectWithTag(Tags.player).transform; smoothCam.player = playerTransform; emptyCursorTransform = GameObject.FindGameObjectWithTag(Tags.cursor).transform; emptyCursorTransform.gameObject.GetComponent<FollowCursor> ().defaultFloorHeight = defaultFloorHeight; smoothCam.cursor = emptyCursorTransform; smoothCam.enabled = true; playerTransform.GetComponent<LookAtGameObject> ().target = emptyCursorTransform; followGameObject = cameraMain.GetComponentInChildren<FollowGameObject> (); followGameObject.followedGO = playerTransform.gameObject; }
void OnControllerColliderHit(ControllerColliderHit hit) { Rigidbody body = hit.collider.attachedRigidbody; if (body == null || body.isKinematic) { return; } Vector3 pushDir = new Vector3(hit.moveDirection.x, 0.1f, 0); if (hit.moveDirection.y < -0.3f) { bouncingOnEnemy = true; // pushDir = new Vector3(-controller.velocity.x, Mathf.Abs(controller.velocity.x), 0); // pushDir *= 0.1f; ParticleSystem particleSystem = GameObject.Find("OrangeExplosion").GetComponent <ParticleSystem>(); Vector3 position = hit.gameObject.transform.position; particleSystem.transform.localPosition = new Vector3(position.x, position.y, -1); particleSystem.Play(); Animator orangeSplatAnimator = GameObject.Find("orangejuice_0").GetComponent <Animator>(); orangeSplatAnimator.SetTrigger("StartAnimation"); if (GameObject.Find("orangejuice_0").GetComponent <FollowGameObject>() == null) { GameObject.Find("orangejuice_0").AddComponent <FollowGameObject>(); } FollowGameObject follow = GameObject.Find("orangejuice_0").GetComponent <FollowGameObject>(); follow.gameObjectToFollow = Camera.main.gameObject; follow.offset = new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), 2.0f); // orangeSplatAnimator.transform.localPosition = Camera.main.transform.position + new Vector3(0, 0, 2); // new Vector3(position.x, position.y, -2); GameObject.Destroy(hit.gameObject); return; } body.AddForce(pushPower * pushDir); }
//[RPC] private void SetupNewFire(GameObject gameObject, GameObject objectComponent, bool isLargeFire, bool nearBigFire) { GameObject gameObject1; Flamable component; try { gameObject1 = /*NetworkView.Find(objectID).*/ gameObject; component = /*NetworkView.Find(creatorObjectID).GetComponent<Flamable>()*/ objectComponent.GetComponent <Flamable>(); } catch (UnityException ex) { Debug.Log(ex); return; } FollowGameObject component2 = gameObject1.GetComponent <FollowGameObject>(); component2.follow = component.gameObject; component2.distance = component.fireOffsetLocaiton; component.fireAnimate = component2.GetComponent <FireAnimate>(); component.fireAnimate.fireBase = component; component.nearBigFire = nearBigFire; }
public void Spawn() { print("Spawning!"); Camera.main.transform.rotation = Quaternion.Euler(0f, 0f, 0f); Camera.main.transform.position = Vector3.zero; Transform transform = /*Network.*/ Instantiate(player, gameObject.transform.position, gameObject.transform.rotation /*, 0*/); /*if (PlayerPrefs.GetString("Username") == "Kritz") * { * networkView.RPC("SetPlayerTexture", 6, new object[] * { * transform.networkView.viewID, * "Kritz" * }); * } * else * { * networkView.RPC("SetPlayerTexture", 6, new object[] * { * transform.networkView.viewID, * Random.Range(1, 8) + "staff" * }); * }*/ menu component = Camera.main.GetComponent <menu>(); MouseLook component2 = Camera.main.GetComponent <MouseLook>(); FollowGameObject component3 = Camera.main.GetComponent <FollowGameObject>(); foreach (object obj in transform.transform) { Transform transform2 = (Transform)obj; foreach (object obj2 in transform2.transform) { Transform transform3 = (Transform)obj2; transform3.GetComponent <MeshRenderer>().enabled = false; } transform2.GetComponent <MeshRenderer>().enabled = false; } component.enabled = false; component.currentMenu = menu.MenuGUIStates.pauseMenu; component2.enabled = true; component3.follow = transform.gameObject; component3.enabled = true; /*transform.networkView.RPC("SetUsername", 6, new object[] * { * transform.GetChild(0).FindChild("Username").networkView.viewID, * PlayerPrefs.GetString("Username") * }); * component.networkView.RPC("GetPlayerUsername", 0, new object[] * { * Network.player.externalIP, * PlayerPrefs.GetString("Username") * });*/ /*if (PlayerPrefs.GetFloat("sensitivity") == 0f) * { * PlayerPrefs.SetFloat("sensitivity", 10f); * } * component2.sensitivityX = PlayerPrefs.GetFloat("sensitivity"); * component2.sensitivityY = component2.sensitivityX;*/ FirstPersonControl component4 = transform.GetComponent <FirstPersonControl>(); component4.cam = Camera.main; Cursor.visible = true; }
void Awake() { followGameObject = GetComponent <FollowGameObject>(); }