CompanionLink Pooling ?

Hello everyone,

A) im trying to use the CompanionLink for Projectiles “ParticleSystem” but i need to pool them instead of instantiating new ones multiple times per frame.

  • my current Projectiles workflow:
  1. each weapon has it’s Trail effect AddressableID, at runtime when a weapon shoots, a projectile Entity is created and requiring a following effect.
  2. a ComponentSystem is using FollowingEffectsRequests to get a GO from the pool and link it to the Entity using CopyTransformToGameObject CD.
  3. when a Projectile Entity is Destroyed another ComponentSystem uses a ComponentDataSystemState to pool the used Go.
  • is it worth it or is CompanionLink optimized for these things?

Also.
B) im trying to link my Camera to an Entity using CompanionLink but im getting Errors.

Authoring:

[DisallowMultipleComponent]
[RequiresEntityConversion]
public class CameraTagAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        // Debug.Log($"Region : X:{Config.value.x} Z: {Config.value.y}");
        dstManager.AddComponent(entity, typeof(CameraTag));
        // Set this Singleton
        ClientGameManager.MainCameraEntity = entity;

        conversionSystem.AddHybridComponent(Camera.main);
    }
}

Error:

InvalidOperationException: The entity does not exist
Unity.Entities.EntityComponentStore.AssertCanAddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/EntityComponentStoreDebug.cs:315)
EntityDataAccess.AddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/EntityDataAccess.cs:277)
Unity.Entities.EntityManager.AddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/EntityManagerChangeArchetype.cs:188)
Unity.Entities.EntityManager.AddComponentObject (Unity.Entities.Entity entity, System.Object componentData) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/EntityManagerChangeArchetype.cs:818)
Unity.Entities.Conversion.GameObjectConversionMappingSystem.CreateCompanionGameObjects () (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionMappingSystem.cs:802)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
Unity.Entities.Conversion.JournalingUnityLogger:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/GameObjectConversion/JournalingUnityLogger.cs:50)
UnityEngine.Debug:LogException(Exception, Object)
Unity.Debug:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/Stubs/Unity/Debug.cs:29)
Unity.Entities.Conversion.GameObjectConversionMappingSystem:CreateCompanionGameObjects() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionMappingSystem.cs:817)
Unity.Entities.GameObjectConversionUtility:Convert(World) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:154)
Unity.Entities.ConvertToEntitySystem:Convert() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/ConvertToEntity.cs:172)
Unity.Entities.ConvertToEntitySystem:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities.Hybrid/ConvertToEntity.cs:67)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ScriptBehaviourUpdateOrder.cs:200)

You don’t need to add the hybrid component since the Entities package already comes with a CameraConversionSystem that does it for you.

the CameraConversionSystem is creating 3 Issues.

  • URP not working correctly. (outlines)
  • Post Processing working only in SceneView window.
  • any sound will throw this warning:
    There are no audio listeners in the scene. Please ensure there is always one audio listener in the scene

1 Like

find all cameras in scene, get your main one and set it as the main camera. this new system drove me nuts given it always makes a hybrid camera :slight_smile:

It’s not creating any issues, it’s just converts Сamera, obvious that all other things like volumes, listener etc. not converted “magically” you should convert them by yourself, write simple ConversionSystem which converts that things same as Camera - just add them by AddHybridComponent, like that for PPL in built-in pipeline
5726425--600241--upload_2020-4-17_13-59-10.png
5726425--600244--upload_2020-4-17_14-2-3.png

3 Likes

@eizenhorn that solved my problem :slight_smile: Thanks!

anyone can help me pooling problem ?

I have the same problem “InvalidOperationException: The entity does not exist” when I use Coverty To Entity and the object’s child has static enable.

I’m not 100% sure but I remember reading somewhere a transform system is where the child component is added , and making it static it never get picked up by that transform system. 99% sure my memory has failed me here

1 Like