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. Dismiss Notice

Showcase Parallel State Events

Discussion in 'Physics for ECS' started by tertle, Sep 21, 2023.

  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    Was meant to show this off a couple of months ago but I forgot but came up again recently on discord.

    The state components in the physics sample are quite popular and very useful: https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/PhysicsSamples/Assets/6. Events/Scripts/Stateful

    However they're pretty slow because it's all implemented single threaded. A couple of months ago I rewrote it to work in parallel to provide a pretty significant speed up with the exact same behaviour for the user.

    upload_2023-9-21_9-25-22.png

    Left of the red line is the implementation for the physics sample. Right of the red line is my implementation.
    Source if anyone wants it: https://gitlab.com/tertle/com.bovinelabs.core/-/tree/master/BovineLabs.Core.Extensions/PhysicsStates

    The only difference with the sample behaviour and my implementation is I removed the EntityA field as my implementation ensures EntityB is always the other entity so you don' t need to check this.

    Note, I also have plans at some point to add support to netcode prediction for this as well with manual rollback, but as I am currently not working in a netcode project this will be a little while~
     
    Last edited: Sep 21, 2023
    calabi, apkdev, philsa-unity and 2 others like this.