Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question about Kinematic and TriggerEvent

Discussion in 'Physics for ECS' started by jennal, Dec 10, 2022.

  1. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    Hi, I want to pause my game, I try to get the SimulationSystemGroup, and set Enabled to false. It is working good.
    But when I set Enabled back to true. I found that FixedStepSimlationSystemGroup has been update too many times in one single frame base on my pause duration.
    The longer pause duration the more OnUpdate called on FixedStepSimlationSystemGroup. Is this a bug or feature?

    Is it a catch up? Can I disable catch up?

    I have bullets and characters with kinematic rigidbody, so I can control the way of movement fully. When collision happen, it will make a TriggerEvent.

    I put MoveSystem in FixedStepSimulationSystemGroup, because if I put it outside FixedStepSimulationSystemGroup, bullet may pass through monsters without collide hit.

    What is the correct way to work with kinematic and TriggerEvent?
     
  2. jennal

    jennal

    Joined:
    Oct 28, 2017
    Posts:
    24
    I found a solution by my own.
    Just put this code to replace default RateManger, and catch up gone.

    Code (CSharp):
    1. var systemGroup = World.DefaultGameObjectInjectionWorld.GetExistingSystemManaged<FixedStepSimulationSystemGroup>();
    2. systemGroup.SetRateManagerCreateAllocator(new RateUtils.FixedRateSimpleManager(0.02f));
     
    Tudor and JMPM-UNITY like this.