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

Very Low fps.

$
0
0
Hi there! I have script wich realizes creatures behaviour. If there are 3 or more monsters with this scripts FPS will become very low. If i delete all Update methods (Update(), FixedUpdate(), LateUpdate()) fps rises. So can u advice me please how to rewrite my code to archieve normal fps in my game. 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); } } }

Viewing all articles
Browse latest Browse all 93

Trending Articles



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