Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question "subscribe" to simulate calls, how?

Discussion in 'Physics' started by Unifikation, Jan 26, 2023.

  1. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,073
    If I'm using manually calling Simulate in a second scene, and I want to put in some logic that gets called each cycle of the Simulate call, do I just do that through FixedUpdate() and can I then be sure this is not regularly being also called by the other Scene that's not manually being simulated by me, but is instead doing its physics automatically at the fixed step rate?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,082
    FixedUpdate is not physics. FixedUpdate is a core part of the Unity Playerloop (same as Update etc) that calls, amongst other things, physics systems but also animation, the scripts etc.

    Manually simulating physics does just that, there and then. There are no callbacks beyond the usual physics callbacks. Again, FixedUpdate is not a physics callback.

    If you're simulating then you can perform your own callbacks/events etc.
     
    Unifikation likes this.
  3. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,073
    So have to make a List<> of some sort and subscribe all the objects that need a call, like that kind of manual thing?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,082
    Use an event on some "game manager" that things subscribe to then simply invoke the event when you have just simulated.