Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Should it be possible to edit a PhysicsMaterial asset at runtime and see the change live?

Discussion in 'Physics' started by Xarbrough, Sep 12, 2019.

  1. Xarbrough


    Dec 11, 2014
    I have a PhysicsMaterial2D applied to a few colliders in my scene and tried to tweak the friction and bounciness values at runtime. However, I quickly noticed that the values are not reflected in the live simulation. Instead I needed to disable and re-enable all colliders or restart play mode to see the changes.

    I understand that this may be a limitation of communicating with the physics middleware, but it could also be a bug, so I wanted to ask in the forum.

    If this is intended behavior I would like to suggest to show a small info text on the PhysicsMaterial2D inspector when in play mode, e.g. "Changes made in play mode will only be applied when affected colliders are toggled.".
  2. MelvMay


    Unity Technologies

    May 24, 2013
    No, this isn't a live asset that is read each simulation step. If you change it you'll need to reassign it, no need to disable/enable the collider.

    It's a frustrating limitation that would require a significant change to Box2D to get this working. So far it's not been a high priority but I understand it's kind of annoying.

    In the meantime I'll look at updating the docs and making the behaviour more obvious.
    Xarbrough likes this.