Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question OverlapSphere returns destroyed Entites

Discussion in 'Physics for ECS' started by Nilokilo, Mar 19, 2024.

  1. Nilokilo

    Nilokilo

    Joined:
    Oct 21, 2020
    Posts:
    17
    I have a problem where i destroy the Entity in the InitializationSystemGroup but when i do CollisionWorld.
    OverlapSphere() it still returns that destroyed entity and i have to make the Exists() checks for no reason..

    Since the Initialization group runs before the Physics group and the OverlapSphere check i am doing runs AFTER the entire Physics group i have no idea how to fix it. Any solution would be appreciated.
     
  2. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    844
    Which system group is your own OverlapSphere-using system executing in, is it somewhere inside FixedStepSimulationSystemGroup? If not, it could be that the fixed step doesn't happen for a specific frame and the physics data is stale since it only runs in FixedStepSimulationSystemGroup. Start by making sure anything that relies on up-to-date physics is itself updating within the FixedStepSimulationSystemGroup.
     
  3. Nilokilo

    Nilokilo

    Joined:
    Oct 21, 2020
    Posts:
    17
    As i wrote it's after the FixedStepSimulation. But i put it now into FixedStepSimulationGroup and it worked thanks but that's not a very nice thing to do since there are many overlap checks happening and when FixedUpdate gets called multiple times per frame it drops the fps even more. Best thing to do is probably setting the simulation mode to Update.