Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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:
    106
    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. JosepMariaPujol

    JosepMariaPujol

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    84
    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.
     
    Volshar and Occuros like this.
  3. morphex

    morphex

    Joined:
    Dec 18, 2012
    Posts:
    106
    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
     
    JosepMariaPujol likes this.