Forum rules - please read before posting.

Very slow start-up when scene has many objects

Hello,

I am new to Adventure Creator and am hitting an issue with long startup times when using Unity's play in editor feature.

A popular technique for building levels is to construct them from many reusable modular set pieces.  My 3D game scene uses this technique.  These tiles are marked as static.  My current map has around 200 of these geometry prefab instances all parented to an empty named 'Geometry'.  They are untagged and set to layer Ignore Raycast.  These tiles each have their own colliders using Unity's physics system (characters can walk on them).  I have opted for Unity's pathfinding and baked the navmeshes.  I am using Unity 4.6.2f1 and Adventure Creator 1.42c

Here are some benchmarks of time from when I click the play button to when the game is playable (these are approximate since I'm timing using a stopwatch by hand)
World geometry disabled + GameEngine disabled = ~2 seconds
World geometry enabled + GameEngine disabled = ~2 seconds
World geometry disabled + GameEngine enabled = ~2 seconds
World geometry enabled + GameEngine enabled = ~18 seconds

It looks like the AC GameEngine is interacting with the world geometry at start-up, although being new to AC, I'm not sure why it would need to.  As I add more geometry to the world, I imagine this start-up lag will continue increasing.

Can you please advise as to why startup is so slow when many objects are placed and anything I can do to mitigate this issue?

Thanks!

Comments

  • edited February 2015
    I noticed this slow too.
    But I think it came with the new version of Unity, not AC.

    I'm still using 1.40b from long time (because it has everything I need for now) and I noticed this slow-down after upgrading to U 4.6.2f1.

    I don't have 18 sec but 6-7 sec. Before was 2-3 sec.
  • I can't tell whether or not this is AC or Unity, but AC shouldn't be interacting with the geometry like that.  There are a few things we can try to narrow down the source:

    1) Try switching to MeshCollider pathfinding.  No need to supply a NavMesh object - just switching it should be enough to see if it makes a difference

    2) Disable the colliders on your world geometry.  You should be able to do this in one by bulk-selecting them.
  • edited February 2015
    Some interesting results...  toggling the nav settings has no effect, and disabling box collider has no effect but does cause the below error to be reporting about 2k times.  Out of curiosity, I *deleted* the box collider, and performance is 90% solved.

    It looks like IgnoreNavMeshCollisions() has a O(n^2) loop with a call to the physics engine, which seems is scaling very poorly.  Commenting out IgnoreNavMeshCollisions() inside GatherObjects() allows me to start with only a three second startup time (would prefer 2sec, but it's still way better than 18sec ;) )

    Out of curiosity, why does AC ignore nav mesh collisions?  Is it safe to skip this if I'm using stock Unity pathfinding?

    ---

    Ignore collision failed. Both colliders need to be activated when calling this IgnoreCollision
    UnityEngine.Physics:IgnoreCollision(Collider, Collider)
    AC.StateHandler:IgnoreNavMeshCollisions() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:110)
    AC.StateHandler:GatherObjects() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:97)
    AC.StateHandler:GetReferences() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:85)
    AC.StateHandler:Awake() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:50)
    UnityEngine.Object:Instantiate(Object)
    AC.KickStarter:Awake() (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:743)

  • That function had to be added because Unity 5 doesn't allow for non-convex trigger colliders.  I will see about disabling it for Unity 4 users in the next update, but at the moment I don't know of a better way to get around the rather annoying change that Unity 5 brings.
  • Ah, I haven't tried Unity 5 yet.  Would it also be good to disable the function for users who are using stock unity pathfinding?
  • I don't think so: as you still need NavMesh colliders present. (You using AC's "Unity Navigation" option, and not a custom solution?)
  • Yes, I am using the Unity Navigation option under pathfinding method.  Running the function or not doesn't seem to have much effect for me, although I'm only using pathfinding in one situation.  When my character talks to my test NPC, she pathfinds to a specific marker to start the conversation.

    Unfortunately, a lot of the time she prefers to turn in endless circles :P  But this doesn't seem to affected by the script change or not.
  • The spinning effect could well be down to your "Destination accuracy" slider in the Settings Manager.  If your game was built at a different scale to AC's (model-wise) you may have to lower the slider's value a little.
  • I just noticed this too, certainly a new thing, my scene literally takes minutes to start up! Without AC its under 10 seconds. I wonder if the Unity5 conversion process wrecked something.
  • Commenting out IgnoreNavMeshCollisions works for me too, goes from minutes of waiting to about 12 seconds, my scene is very complex. 
  • That did the trick to solve the spinning, thanks!
  • I'm also getting all those "Ignore collision failed" errors. In this level, we have a custom nav mesh with a MeshCollider on it and we're using Unity Navigation. For now I'm going to add the same Unity 5 compiler directive that's in PlayerInput.
  • Thanks for the alert.  I'm atop of things.  v1.43 should make things work much better in this area.
  • Awesome! Hope you make a living from this Chris lol.. or you must spend your nights on this forum, excellent work with the speed of updates btw.
  • same problem here- scenes with much objects are loading very long. doesnt make it possible to work currently with it. is there any fix?
  • You will need to post more info than that - refer to the first post in this thread as an example of the kind of detail you'll need to provide.
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.