In class Thursday I was able to create a functioning particle that would duplicate itself in order to connect to resource nodes I had 2 major problems: 1 updating so many gameobjects was causing a massive bottleneck, 2 gameobjects would duplicate into eachother. I'm working on a fix to reduce massive clusters of objects by representing them as a cluster via a larger object in their place while deleting the group of objects as well I've removed their rigidbody so that the amount of physics calculations is minimal, they are currently only a mesh and a collider. 1 problem was using the collision functions as they are reliant on gameobjects so instead I've used a new function I came across: "OverlapSphere" which outputs a list of colliders in a radius. I am unsure of how this function works, I can only assume it functions similarly to a raycast in how it's calculating 3D space without using physics. I've used this function to gather the duplicating objects around each and delete any that begin overlapping, problem is that more struggle to fill in it's place leading to the same result however after time it seems to find a medium where it has connected to the node and doesnt overlap. The main issue now its that when I try to scale up the duplicates the collisions cause it to be deleted by the other duplicates now overlapping, I'm going to attempt to build a heirarchy, as simple int that prioritizes larger duplicates over smaller to prevent deletion.
When I was researching new tools I came across 2 interesting objects, The first was Unity's scriptableObject Im unsure how to properly use them but they seem limited in how they effect the Scene unlike MonoBehaviour which can interact with Unity's refresh and physics routines. Another useful object was the C# base class type, unlike scriptableObjects these could be written to in the Unity editor inspector by using the Serializable attribute which access of classes in Unity whereas scriptableObjects simply gives us a namespace for object that would be the same for each. The significance of this is that I can now attach this to a multitude of objects but manually customize different prefabs with the same script. This I unfortunately tested in my IRIS game project as I was working on this on a break and as the Virtual project is more procedural based but I feel like this is definitely a useful tool. I will need to test accessing and adding it to Gameobjects in game time to see if it's stable for that purpose before I start using it standard.
A serialized class and Scriptable Object List, the standard class can be edited while the scriptable can only be referenced. |
MonoBehaviour and contained data classes for editor above |
No comments:
Post a Comment