Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Best way to get PhysicsWorldSingleton from MonoBehaviour

Discussion in 'Physics for ECS' started by slushieboy99, Feb 6, 2024.

  1. slushieboy99


    Aug 29, 2014
    Hi all,
    I've been trying to scour the forums for any information on this, it seems really obtuse to retrieve the PhysicsWorldSingleton from Monobehaviour. As far as I've found the best way to do this is the following:
    Code (CSharp):
    1. World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntityQuery(typeof(PhysicsWorldSingleton)).GetSingleton<PhysicsWorldSingleton>();
    This is pretty ugly and makes me feel like I'm doing this incorrectly. Is there a better way I should be doing this?