Any ECS + Netcode + Unity.Physics examples

I can’t get this to work. I am adding a physics body and a physics shape to my objects that are static and a ghost component to those that are dynamic but I am getting nothing. Any examples anywhere?

Hi,

We have a Physics sample in NetcodeSamples\Assets\Samples\MultyPhysicsWorld which should help.

Thanks,

Sam

I was aware of that sample, I guess I was confused about non ecs physics components (rigidbody, colliders) being bakes to unity physics through a subscene.

I can add these to my project and it works fine, the only question i have is that it interacts with physics objects outside of the subscene (those that are not in a subscene at all)

ECS physics doesn’t interact with GameObject physics in any way, as they’re two completely separate systems.

InvalidOperationException: Expected simulation type: UnityPhysics, current simulation type is: NoPhysics

I have tried adding Net Code Physics Config, and Physics Step.

I am loading the subscenes programmatically if that makes a difference.

I figured it out, first make sure your scenes are actually subscenes and not additional scenes. Subscenes are gameobjects with a subscene script. It can be easy to lose your subscene data when double-clicking on a scene (often out of project).

Ghost components only need to be added to dynamic physics objects. Add the physics shape component and if necessary add a physics body and ghost component. Ensure all the objects are prefabs, having them not will prevent it from working.

1 Like