Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Discussion Unity Physics for GameObjects. Why not?

Discussion in 'Physics for ECS' started by Vectrex, Sep 5, 2023.

  1. Vectrex


    Oct 31, 2009
    I'll get burnt alive for even asking this, but.. I've never seen anyone talk about just making GameObjects be able to directly interact with the ECS Unity Physics world. Why?
    I see a lot of arguments about interoperability between PhysX and Unity Physics saying it's a terrible idea, fair enough, so just... don't do that?

    Ok calm down, you're going to have a heart attack. My arguments are these..
    • All the sync issues would go away since the physical world is the same.
    • Incorporating this would massively ease converting the millions of existing projects that would benefit from ECS, as it could be applied gradually without needing a complete rewrite.
    • Companies that are terrified of this unknown could easily test the waters in existing projects and get their programmers to start learning ECS without massive commitment.
    • Unity could automatically bake all GOs marked as static to Entities and UP and still interact with existing GOs. Maybe providing an instant huge speed increase for large worlds?
    • Yes, having GOs trying to wedge their bloated bodies into ECS isn't efficient at all, but I think this might not be an issue if the number of GOs is tiny compared to the number of Entities.
      The editor could even warn you when you're using many GOs with UP and suggest rewriting with ECS, or just straight up tell you it could be slower to use UP until you rewrite enough objects with ECS.
    • These GO components wouldn't need the full set of features, if they truly don't make sense in GO land, a subset is much better than nothing. Even a frame delay to avoid sync points with GO collision event calls would be fine in a lot of situations.
    • How would we tell normal GOs to use UP instead of actual PhysX? Simple, add an ECS tickbox to those components (maybe warn if they mix types in the same GO)
      • I would also argue that using PhysX GO components for Entities that don't interact with actual PhysX GOs is far more confusing, so this would solve two problems.
      • The GO UP components could use the same function and callback names, so a lot of existing code might 'just work'. There could even be a simple upgrade menu item to scan the project and tick the "ECS" boxes for you. Like the material upgrader menu.
    • All the thousands of Unity Store assets might stand a chance of working without too much pain.
    • Sure the 'feel' of the physics would need tweaking, but no-one would expect it to be exactly the same.
    • Designers and less experienced coders could still make OOP objects that work with an ECS project, which if needed could be upgraded to ECS by the experienced coders.
    • A project setting to set the physics engine could allow any added physics components to auto tick the ECS button/grey out non-supported features. Exactly like the Input system options "PhysX, Unity Physics, Both". This could also prompt on importing assets to set them to ECS/UP.
    • I know this would have many complexities and Unity devs have limited time. But think of how massive this would be for everyone if they could dip their projects into ECS one prefab at a time? No point having this great system if everyone doesn't have time, or is simply too afraid to use it. Then they'd see it's not as scary as they thought, but rewriting or starting a new project with pure ECS that you've never used before? That's scary.

    ps Unity could also make ECS just work with PhysX (runs)
    pps GPT4 thought it was 'an intruiging idea' and we must obey AI.
    ppps I thought up the 'drag GOs into project window to make prefabs' idea, so you guys owe me.
    Last edited: Sep 7, 2023
  2. FoodFish_


    May 3, 2018
    I am wondering the same thing. Any way to make this work at all right now? Why would it be so bad to just run existing rigidbody and collider of game objects in the ECS simulation? Unity could automatically update the corresponding mesh renderer of our monobehaviours/gameobjects.

    In other word couldn't gameobject just run Unity Physics, or vice versa (ECS run PhysX)? Seems logical to me.
    Last edited: Sep 6, 2023
    Vectrex likes this.