Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Assertion failed: man.hasComponent<HitBoxOverlapResults>

Discussion in 'Project Tiny' started by SorneBachse, Jan 21, 2019.

  1. SorneBachse

    SorneBachse

    Joined:
    Dec 27, 2012
    Posts:
    62
    Hey!

    I've been stuck with this problem for many hours now and can't seem to figure out what the hell is going on.

    This error:
    Code (CSharp):
    1. uncaught exception: abort("Assertion failed: man.hasComponent<HitBoxOverlapResults>(ce.e),
    2. at: C:/Users/Abdul/Documents/tiny/Runtime/modules/hitbox2d/src/HitBox2D.cpp,700,"). Build with -s ASSERTIONS=1 for more info.
    First off, it refers to a path which isn't even on my computer with that user. Secondly, this happens every time I try and disable an entity:

    Code (CSharp):
    1. namespace game
    2. {
    3.     export class EnemyDestroyFilter extends ut.EntityFilter
    4.     {
    5.         tag: game.EnemyTag;
    6.         destroyTag: game.DestroyMe;
    7.     }
    8.  
    9.     /** New System */
    10.     export class EnemyDestroySystem extends ut.ComponentSystem
    11.     {
    12.         destroyFilter: EnemyDestroyFilter = new EnemyDestroyFilter();
    13.  
    14.         OnUpdate(): void
    15.         {
    16.             this.destroyFilter.ForEach(this.world, (e) =>
    17.             {
    18.                 //EntityUtils.SetEntityEnabled(this.world, e, false);
    19.                 if (!this.world.hasComponent(e, ut.Disabled))
    20.                 {
    21.                     this.world.addComponent(e, ut.Disabled);
    22.                 }
    23.             });
    24.         }
    25.     }
    26. }
    27.  
    The only other place I use the Hitbox2DOverlapResults is in a completely other system, which has nothing to do with this one.
    Code (CSharp):
    1. namespace game
    2. {
    3.  
    4.     export class PlayerCollisionSystemFilter extends ut.EntityFilter
    5.     {
    6.         tag: game.PlayerTag;
    7.         transformPosition: ut.Core2D.TransformLocalPosition;
    8.         hitBoxOverlap: ut.HitBox2D.HitBoxOverlapResults;
    9.     }
    10.  
    11.     /** New System */
    12.     export class PlayerCollisionSystem extends ut.ComponentSystem
    13.     {
    14.         filter: PlayerCollisionSystemFilter = new PlayerCollisionSystemFilter();
    15.  
    16.         OnUpdate(): void
    17.         {
    18.             this.filter.ForEach(this.world, (e) =>
    19.             {
    20.                 GameStateTransitionService.TransitionToGameState(this.world, game.GameState.GameOver);
    21.             });
    22.         }
    23.     }
    24. }
    25.  
    Any help would greatly be appreciated!
     
  2. raymondyunity

    raymondyunity

    Unity Technologies

    Joined:
    Apr 30, 2018
    Posts:
    122
    Thanks for the feedback. We reported a bug about this issue.

    You can probably work around this issue by destroying the entity in a way that the PlayerCollisionSystem does not pick it up. So try adding an if statement to check if the DestroyTag exists. Better to also use a raw system and you can use subtractive queries to ignore entities with the DestroyTag component.
     
  3. SorneBachse

    SorneBachse

    Joined:
    Dec 27, 2012
    Posts:
    62
    Thank you for this. I'm not sure how subtractive queries work. Can you give an example, or link to somehere I can find it?

    EDIT: Unfortunately I couldn't get any of your suggestions working. Even when the PlayerCollisionSystem wasn't running, meaning it shouldn't catch any collisions, this error still came everytime I tried disabling it.
    I switched to a destroy/instantiate method for now.

    EDIT2: So! It actually seems I got it working, after reading this thread:
    https://forum.unity.com/threads/invalid-entity-deleted-error.614443/#post-4129555

    Apparently it happens because my enemies are children of the spawner, so I had to remove all children of the spawner initially.
    Is there any particular reason for this, or is it a bug?
     
    Last edited: Jan 22, 2019
  4. raymondyunity

    raymondyunity

    Unity Technologies

    Joined:
    Apr 30, 2018
    Posts:
    122
    After some investigating, it looks like it is a bug. Do not use "this.world.DestroyEntity()".

    Use "ut.Core2D.TransformService.destroyTree(this.world, entity);" instead. This should also remove the children if the node has any.
     
  5. SorneBachse

    SorneBachse

    Joined:
    Dec 27, 2012
    Posts:
    62
    Alright, thank you. I'm gonna give that a go tomorrow, and report back.