Hi! Can anyone tell me how to get the BuildPhysicsWorld to access the Collision World in order to make an OverlapSphere function for entities?
Added 2 pictures with the code that worked just fine in 0.51 and the new Console error after upgrading to 1.0.
#Help transitioning from 0.51 to 1.0. BuildPhysicsWorld.
1 messages · Page 1 of 1 (latest)
tldr that stuff is on a singleton now in order to enable access from bursted isystems if desired
Thank you! I’ll check it out 
@odd canopy I just tried to use SystemAPI but unfortunately I can't use this in a Monobehaviour. Is there a way to do it outside a SystemBase?
no, systemapi doens't work outside a SystemBase or ISystem; you can use entitymanager though
And how can I use EntityManager to get the PhysicsWorldSingleton then?
@odd canopy I'm trying to use it entitymanager by using CreateSingleton and entityManager.World.GetExistingSystemManaged but I can't make it work
what are you trying to do overall? in general, i wouldn't think trying to talk to entities this much from a monobehaviour would be the best plan
I'm just trying to get the CollisionWorld in order to be able to do a OverlapSphere function in order to detect collisions. And I did this in 0.51 without an issue. I want to do it inside a monobehaviour because that's where I do most of the logic of what I want to do.
have you tried entitymanager.GetSingleton?
and have you established that this code is running after the code that creates the physics world singleton? in a system, this is easy to do with RequireForUpdate<PhysicsWorldSingleton>, but in a monobehaviour it's trickier
entitymanager.GetSingleton() doesn't exist in the list of options apparently
ehm
TIL
@runic drum how do you get a singleton from outside a system
i guess you have to manually GetEntityQuery and then assert that there's only one thing in it
How do I do GetEntityQuery?
I can only create it with EntityManager
Or did you mean create?
yeah create, but it caches it so it's secretly getorcreate
this api surface is so annoying
Sry for making so many questions but what do I exactly put in CreateEntityQuery?
PhysicsWorldSingleton?
Ok but I'm kinda confused
I'm trying this:
EntityQuery PWS = entityManager.CreateEntityQuery<PhysicsWorldSingleton>();
And it throws an error
Should it be like this?:
EntityQuery PWS = entityManager.CreateEntityQuery(ComponentType<PhysicsWorldSingleton>());
yes
It throws me this error:
error CS0308: The non-generic type 'ComponentType' cannot be used with type arguments
sorry i forgot everything
EntityQuery PWS = entityManager.CreateEntityQuery(ComponentType.ReadWrite<PhysicsWorldSingleton>());
Keep in mind, you should remember to dipose queries yourself created with entityManager.CreateEntityQuery. So ideally use EntityQuery PWS = new EntityQueryBuilder(Allocator.Temp).WithAll<PhysicsWorldSingleton>().Build(entityManager); instead. EntityQueries created with EntityQueryBuilder is automatically disposed. For .Build(EntityManager) disposal happens on world destruction.