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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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,075
    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:
    114
    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)