Search Unity

Question Change PhysicsCollider at runtime

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by optimise, Dec 8, 2022.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    At dots netocode, I believe when u try to change PhysicsCollider data at runtime like changing size it will not sync data to both client and server since it's using blob asset. Does it means I need to create custom component to handle this? Or is there any plan to make blob asset possible to sync data to both client and server in future?
     
    goncalo-vasconcelos likes this.
  2. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    I'd recommend doing something like this:
    • Create a "ColliderSize" Component, with a "float Size" ghost field
    • Have a system that runs on both client and server, which sets the size of the collider based on that "Size" value
    In other words; control the size of the collider based on some ghost field in a ghost component, and avoid changing the size every frame by only changing it if it's different from the current size (you may want to store the last applied size in a non-ghosted field for quicker comparison)