Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Physics and Netcode integration.

Discussion in 'Physics for ECS' started by morphex, Mar 7, 2023.

  1. morphex

    morphex

    Joined:
    Dec 18, 2012
    Posts:
    112
    I am trying to prototype a multiplayer game using ECS and the new physics engines, and I struggling to find how we are supposed to integrate both of the systems together.

    So I created a scene, and added a plane with the PhysicsShape Plane onto it - this is my ground.

    I tried to Raycast against the floor on a client system, by creating a Ray pointing straight down, but it does not find the collision.

    Does my static geometry need to be on a separate ClientPhysicsWorld with the PhysicsProxy as well if I want to run queries against it? I tried adding a Cube with Body/Shape, but it complained that dynamic objects need to be Ghosts (which I understand, they are server simulated).

    Do I need to something else for this to work?

    Is there any demos that showcase both ECS/Physics/Netcode in one go? I cant seem to find anything on the sample repo that would help me out.


    Thank you!
     
  2. JMPM-UNITY

    JMPM-UNITY

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    93
    We have a sample that shows how to use physics and netcode in the NetcodeSample/Hellonetcode.
    In 1.0-pre.XX you don’t need to do anything special. They work out of the box. Repo: https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/NetcodeSamples

    However, in this case, it is hitting a limitation of the current implementation. You need to have at least one predicted ghost in the scene (it can be the player or anything else).


    Physics simulation is not running on the client if there aren’t predicted ghost with a PhysicsVelocity component.
     
    JinxMD, Volshar and Occuros like this.
  3. morphex

    morphex

    Joined:
    Dec 18, 2012
    Posts:
    112
    I have been looking all the samples, and missed the only one that showed what I wanted. *.*

    That limitation was what tripped me up - if that`s on the docs I 100% missed it - if it isn`t, Its something that probably worth mentioning in the integration page.

    That solved my problem :)
    Thank you
     
    JinxMD and JMPM-UNITY like this.