Quantcast
Channel: Questions in topic: "ping"
Viewing all articles
Browse latest Browse all 93

Very Low FPS

$
0
0
Hi! I have very very low fps in my game. My creatures have behaviour script attached and if i remove this script or at least Update() functions fps will become normal. So suggest me please something to fix in my code to make fps higher! // Update is called once per frame void Update() { if (gameObject.transform.rotation != spawnRotation) { //this.gameObject.transform.rotation = Quaternion.AngleAxis(rotOffset, Vector3.up); } if (networkView.isMine) { if (target != null && isAlive && startAggro && target.GetComponent().isAlive) { Attack(target); } } Die(); curHP = Mathf.Clamp(curHP, 0, maxHP); if (isAlive) { if (checkForReAggro && attackersList.Count > 1) { StartCoroutine(AggroDontHitRecovery(attackersList.Last())); if (toggleToOtherTarget) { AdjustTarget(attackersList.Last()); toggleToOtherTarget = false; } } if (_bUpdateRestoreHpAfterRunaway) { StartCoroutine(WaitAfterRunAwayForRestore()); _bUpdateRestoreHpAfterRunaway = false; } else { _bUpdateRestoreHpAfterRunaway = false; } } } void LateUpdate() { if (_allowWaypointMove && isAlive && GameObject.Find("MainCamera").GetComponent().connected) //!It used to be in FixedUpdate 11.01.15 / 0:12:00 { WaypointMovement(); } } void FixedUpdate() { if (isAlive) { Aggro(); } if (networkView.isMine) { networkView.RPC("AdjustThePos", RPCMode.AllBuffered, this.transform.position); networkView.RPC("AdjustTheRot", RPCMode.AllBuffered, this.transform.rotation); } if (GameObject.Find("MainCamera").GetComponent().connected && this.gameObject != null) { if (isAlive) { networkView.RPC("AdjustSpeed", RPCMode.All, (transform.position - lastPos).magnitude); networkView.RPC("SendFloat", RPCMode.All, "Speed", speed); } } if (target != null) { if (!(target.GetComponent().isAlive)) { networkView.RPC("KilledTarget", RPCMode.All); } } } And WayPoint movement: public void WaypointMovement() { if (networkView.isMine) { wayPointMovementTime += Time.deltaTime; //current? if (_flagWayPoint1) { wayPointRot = Random.Range(0, 360); transform.eulerAngles = new Vector3(0, wayPointRot, 0); _wayPointDir = transform.TransformDirection(Vector3.forward); //Skipped _timeRadius = Random.Range(0.1f * wayPointMaxRadius, wayPointMaxRadius); /*if (networkView.isMine) { networkView.RPC("AdjustTheTimeRadius", RPCMode.AllBuffered, (float)Random.Range(0.1f * wayPointMaxRadius, wayPointMaxRadius)); }*/ _flagWayPoint1 = false; } if (!_flagWayPoint1 && wayPointMovementTime < _timeRadius) { _flagWayPoint2 = true; _wayPointDir.y -= 20.0f * Time.deltaTime; //gravity _controller.Move(_wayPointDir * Time.deltaTime * wanderingSpeed); } else { if (_flagWayPoint2) { StartCoroutine(DoTheWay()); _flagWayPoint2 = false; } //wayPointMovementTime = 0; } } else { this.gameObject.transform.position = wayPointClientPos; this.gameObject.transform.rotation = wayPointClientRot; } } IEnumerator DoTheWay() { _nextGoTime = Random.Range(2f, 9f); /*if (networkView.isMine) { networkView.RPC("AdjustTheTimeStand", RPCMode.AllBuffered, (float)Random.Range(2f, 9f)); }*/ yield return new WaitForSeconds(_nextGoTime); _flagWayPoint1 = true; wayPointMovementTime = 0; }

Viewing all articles
Browse latest Browse all 93

Trending Articles