Forum rules - please read before posting.

Removing GameObject

It seems after updating to 1.42x there is a problem with removing gameObjects. Now when i pick up an item and remove it via interaction, the game pauses 1 second before it dissapears. I call an ActionList for this (remove hotspot, remove object, add inventory item) - I tried only to remove the object without calling the ActionList, same problem. Any Idea?


Thx!

Comments

  • By what method did you remove the object, if not through the ActionList?
  • edited February 2015

    Interaction-> ActionList : TakeItem (hotspot2Remove, gameObject2Remove, inventoryItem2Add)

    The interacation 'UseMeasurteTape' calls 'TakeItem' (ActionList) with 3 params and 'TakeItem' will remove hotspot, object and add inventoyItem. This worked before.

    Then i try to remove that object in the interaction directly, without calling the ActionList "TakeItem" and without removing hotspot and without adding inventory item. But the problem is the same. Making the object invisible works fine, only when i remove it it will hang 1-2 seconds.

     

  • it seems that it depends on how much objects are in the scene. I've deleted most of them temp. and removed the measureTape-object by the interaction, it was much faster.
  • Any solution for this?
  • Is the event running in background?
  • When you delete an object through Actions, AC will re-evaluate what's left in the scene for it to update.  1.42 fixed an issue where some things were being left out, so this might be the source.

    I'd suggest finding a way to delete them in one go.  Try parenting each of the objects together, so that you can just delete the top-level object, and have them all removed at once.
  • edited February 2015
    I've tried this with only one single object to delete, same problem here. What i meant was not how much objects are in the object to delete, acutally how much objects are in the whole Scene. And it took about 3 seconds for every single object i delete.
  • The delay happens before or after the object is deleted?

    I'm still suspicious that it's the re-evaluation function.  Let's run a test: open up StateHandler.cs and comment out / remove all the lines inside the GatherObjects function - should start line 89.
  • edited February 2015

    before the object is deleted - ok i give it a try...

    This causes a null reference exception. I comment out every line inside the GatherObject function.


    Ok, i instanciate empty Arrays for them, then it worked. Now it's fast.

  • Just wanted to tag onto this thread to say that I'm noticing the same thing.  If I remove an object with an interaction, there's a significant delay where it seems as though the engine locks after I click on the interaction.  I wait a few seconds and it recovers and removes the object.
  • @thmightyzq: OK - hopefully we'll be able to solve yours following this, too.

    @UndyingSprite: This might be a bit tedius, but one (or possibly more) of those lines is the culprit.  Try experimenting with original lines / empty arrays (i.e. just replace one empty at a time) and see if you can find which array in particular is causing the slowdown.
  • edited March 2015

    Hi Chris, figured out that it has nothing to do with the Arrays, the method : "IgnoreNavMeshCollision" causes the dealy.

    First i thought the foreach Loop is the problem, but it's not.

    The Problem is the if-Statement. I guess gettíng NavigationMesh or NavMeshSegment causes the Problem. I will check later which one of These is the culprit.


    if (!_collider.isTrigger && !otherCollider.isTrigger && !(_collider is TerrainCollider) && _collider != otherCollider && (_collider.gameObject.GetComponent<NavigationMesh>() || _collider.gameObject.GetComponent<NavMeshSegment>()))


  • edited March 2015

    Yes, it is those two calls within the foreach in the if-statement:

    _collider.gameObject.GetComponent<NavigationMesh>();


    _collider.gameObject.GetComponent<NavMeshSegment>();

  • Thanks for the info.  That code's an unfortunate side-effect of Unity 5's changing requirements for colliders, but it's causing slowdown in other areas too and really needs to be improved.

    I may post a replacement function for you to test in a bit.
  • edited March 2015
    Ok, let me know when you're done.
  • Sorry - it turns out there's too much to change for me to post it here.  Look out for the changes in the next release.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.