Forum rules - please read before posting.

Strange trigger behavior

I recently upgraded to Unity 5, as I'm sure many here did, and I was playing around with the new features (upgraded from Unity free), but apparently something happened to my triggers.

I have one large terrain scene with many camera transitions, so that naturally uses many triggers. After playing around with the occlusion culling and GI lighting features, as well as some new shaders, I noticed that the navmesh segments I had placed in this scene had appeared, and would not disappear when I click visibility: off.

It seems like the scene manager settings got erased somehow, and I went back to correct it to what it previously was. This fixed the navmesh issues, but I then noticed that the triggers were not working. 

I took a look, and it seems that almost all of the trigger actionlists were erased! For some reason, one trigger still had its action list, but the rest of them defaulted to one "Engine: Change Timescale" action. I also noticed that all of the hotspots' data had been erased, though the interactions those hotspots called still had their actionlists. Also, the names of the hotspots/triggers no longer show up on the scene view, and for some strange reason whenever I select one of the triggers, the "_Triggers" subfolder is selected instead of the single trigger I'm after.

So all in all, this is very bizarre but it also completely erased quite a few hours of work! Can anyone explain this? Is it possible to retrieve the action lists?

Another thing I did was I selected all of the navmesh segments and ticked "Convex" in the mesh collider component, since Unity 5 no longer supports mesh collider triggers when they aren't convex (no clue why). This really screws up the pathfinding, but I believe Chris has indicated that this is something he is working on for the next update.

Oh, and I forgot to mention this only happens in one scene. The rest appear to be unaffected. 

Comments

  • If you're using 1.42c, AC will handle the convex/trigger issue for you automatically.  "Convex" and "Is Trigger" should both be left alone, unchecked.

    The other problems you've reported are very serious, but I need more detail.  Did it affect all scenes or just the one?  Is there a pattern/logic to what was affected, or is it random?  The easier it is for me to recreate the issue, the faster I can issue a fix.
  • I was getting errors with "is trigger " checked without convex checked... are these errors acceptable to have at this point? Also after I checked convex, I noticed I cannot check "is trigger" again without convex... I am not currently at my desktop, is there any way to revert it back to the way you specified?

    As for the trigger and hotspot issue, it only happened in one scene and I think I narrowed it down to Unity crashing when I tried to import a new package (some volumetric fog shader package) and I had an extra library folder in the package that shouldn't have been there, so Unity crashed and informed me I needed to remove the relevant folders on the next startup. After that happened is when I noticed the trigger actionlists missing, in the scene which was active when Unity crashed and when I started it up again.

    So I don't know what exactly happened, and I'm not sure you can recreate it with this info... but for future reference, is there a way to backup scene based actionlists? Also where exaclty are they saved? Is it possible that this information is still saved somewhere in the scene file and I can retrieve it?

    Thanks!
  • If you saved it afterwards, I don't think so, unfortunately.

    Just re-import AC to revert the collision prefab.  When in Unity 5, AC won't rely on them as Triggers, but will instead just use Physics.IgnoreCollision to make sure no characters or anything else will conflict with them.
  • I actually made sure not to save because I was curious if I could close Unity and reopen it to get the actionlists back, but I tried that and it did not work. Also should the trigger/hotspot labels still show up in the scene view as they always have so far? I'm referring too the labels which show up orange or yellow and are always visible for every trigger/hotspot in the scene I'm not seeing them anymore after this issue occured. Perhaps reimporting AC will fix these problems too, I'll try that next time I have a chance.

    Thanks for the quick response!
  • Those labels are a prefab setting - if they're not showing, then either the prefabs have been altered or the links to them have been cut.  When you select a Trigger / Hotspot in the Hierarchy, can you "Select" it at the top of the Inspector to show it's prefab in /AdventureCreator/Prefabs/Logic?  Doesn't sound like things are working well at all, here.
  • Selecting the trigger/hotspot does in fact select the prefab in the logic folder, but it still does not show the labels. Furthermore, I reimported AC and the labels still did not show up, and I got this error: 

    MissingReferenceException: The object of type 'AC_Trigger' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEditor.Editor.IsEnabled () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:530)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1072)
    UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:959)
    UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:340)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    This seems to be a compiler error, and I can no longer run the game. Any ideas?
  • None of the error lines in that block actually reference any of AC's code, so I don't know what to suggest other than starting a fresh Unity 5 project, importing AC and importing a package of your Unity 4 work (minus anything to do with AC) into the new project.
  • Whoops, looks like that error wasn't causing the compiler problem, this was another error:

    Assets/AdventureCreator/Scripts/Variables/GlobalVariables.cs(19,22): error CS0101: The namespace `AC' already contains a definition for `GlobalVariables'

    The previous error had to do with the editor layout window (clearly I've messed up my project quite a bit with all this tinkering!) but it cleared when I restarted Unity. The above error remains though, and I've tried reimporting AC again but I'm left with this error. I also cannot access any of the AC windows until this error is fixed apparently. 
  • So I figured out that the GlobalVariables.cs script should not even be present in that folder, so I removed it and the game mode runs as it should. 

    I also did as you suggested and created a new project with a brand new AC install and just my own assets, and the trigger/hotspot labels still do not appear. The correct prefab is selected when I "select" each instance, so I don't know exactly what the problem is. 

    Also, after I unchecked the trigger and convex settings on the navmesh segments they seem to work correctly, but I do get many continuous errors on the console (which don't appear to cause any additional problems) but I just thought you should be aware of it. The error is:

    Ignore collision failed. Both colliders need to be activated when calling 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)


    Thanks for the help as always!
  • So I had a thought- It looks like the trigger actionlists are gone and I need them replaced, but it seems there was no way previously to back up those actionlists (besides copy/pasting each one into an individual asset based action list).

    So in a future update, if it's possible, can you give us some way to save scene based actionlists in an asset or backup file? If these scripts can get affected by Unity errors and the actionlists erased I think it would save some headaches if we had a way to back them up before we mess with Unity.
  • Because of the way Unity handles ScriptableObjects, it's not possible to prefab scene-based Actions.  However, you can still use ActionList assets to populate your Cutscenes, Hotspot Interactions etc.  Just look for the Source popup at the top of one's Inspector - you can change it to Asset File.
  • So would you recommend just having all of my actionlists be asset based? At least with my funky setup which seems to erase the scene based ones on occasion? 
  • One more thing- when running trigger interactions directly from asset-based actionlists there is no longer an option to define parameters if the actionlist has parameters. Is that something that can be added?
  • Likely not, since the ActionList would have to "know" it's being used by the Trigger beforehand.  Generally I'd recommend using scene-based lists whenever you can.
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.