|
|
|
|
|
something for increasing FPS.
Need to change a list to a dictionary so instead of the array going "Element 0, element 1, etc" i can change the element name to spawnId in objectpool.cs Using "Where" or "Find" hurts performance. I'm trying to find a way to just define a gameobject without having to search for it first. I use this a lot in handleworldmessages.cs. Biggest thing is op_clientupdate uses this 100% of the time, and it is sent from the server to the client every 30milliseconds. in a script other than objectpool.cs, i use the below line to define a gameobject thats in a list array: GameObject temp = ObjectPool.instance.spawnlist.Where(obj => obj.name == spawn_id.ToString()).SingleOrDefault(); Id like to do something like below in a dict array, cutting out the search using the spawnId as the element# in the array, so I don't have to search by name: GameObject temp = ObjectPool.instance.spawndict[spawn_id]; In the pc editor, it's np @ 60 fps. in firefox it's 30fps. In chrome, it's like 17-23 fps. (from what i've noticed). Pretty sure this is causing it. http://i.imgur.com/cEEapHw.png |
The "where" wasnt killing my fps, but changed it to below and kept the spawnlist array a list instead of switching to a dictionary:
GameObject temp = ObjectPool.instance.spawnlist.FirstOrDefault(obj => obj.name == spawn_id.ToString()); This line in npccontroller.cs was taking FPS down by half. grounded = ((controller.Move(moveDirection * Time.deltaTime)) & CollisionFlags.Below) != 0; |
https://docs.unity3d.com/ScriptRefer...ller.Move.html
https://docs.unity3d.com/ScriptRefer...sGrounded.html This says that CharacterController already has a property called "isGrounded" which checks if the characterController was touching the ground during the last move. You might separate the .Move command onto a different line as the bitwise operator function. Also, do you have a range limit set for what objects are rendered? Game clients have an adjustable clip plane (I think that's what it was called in EQ) that only renders terrain and game objects out to a certain distance. It might help if you're only rendering what's in the immediate area instead of every NPC in Qeynos. It's late, so I could be horribly wrong, but since I don't see a good way around having to call the .Move command, the only thing I can guess at is minimizing its usage. |
doing real good on fps now with a bunch of changes.
Clip plane is set to 1200, thats the value in the DB in zone table. Anything past that, the client doesn't render by default. I just added to the NPC script for gameobjects not to render when the camera isnt looking at it. I did this with NPCs only, for now. Code:
Vector3 screenPoint = Camera.main.WorldToViewportPoint(transform.position); https://youtu.be/FSQ7I1EcA08 |
That technique seems to only raise fps by a little bit, trying out another method.
Unity's built in Occlusion Culling: https://docs.unity3d.com/Manual/OcclusionCulling.html |
Quote:
|
FirstOrDefault only returns null if the default is null. The default value can be configured so it works quicker than .FirstOrDefault(obj => obj.name == spawn_id.ToString()) ?? new GameObject();
|
Messing with Analytics and eventually back to bag/equip slots.
Google Analytics Plugin for Unity - API Reference |
|
|
All times are GMT -4. The time now is 11:50 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.