Forum rules - please read before posting.

Turn off an npc and avoid errors from statehandler

I have areas of my city where all NPCs can be off until you get near, I have done this using ACs send message to tunr them on and off. Problem is when theyre off I get many errors like this:

Animator is not playing an AnimatorController
UnityEngine.Animator:SetBool(String, Boolean)
AC.AnimEngine_Mecanim:PlayIdle() (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_Mecanim.cs:689)
AC.Char:AnimUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:801)
AC.Char:_Update() (at Assets/AdventureCreator/Scripts/Character/Char.cs:445)
AC.NPC:_Update() (at Assets/AdventureCreator/Scripts/Character/NPC.cs:132)
AC.StateHandler:Update() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:371)

Is there a way to tell statehandler theyre off and  dont need to be updated in anyway  until theyre back on ?

Comments

  • edited December 2017
    What is it you're trying to do, deactivate their interactivity or stop them moving and animating completely?

    The error message above doesn't line up with the latest release - what version are you using?

    The "TurnOff" message you can send to NPCs currently only changes the layer they're on.  Have you done anything else to warrant the Animator reporting such a message?
  • 1.54c, I want them off entirely, so that they arent visible and use no cpu either, until I get to a trigger. I dont think I have done anything unusual theyre just npcs who idle and animate at times. Actually I am using a custom action to turn them off too, just by turning them off. Actually I just noticed an error in my script, not even sure why it turned them off in the first place, hmm will need to look into this further and get back to you. 
  • If you're using a custom script to do it, then look into calling the GatherObjects method after enabling/disabling an NPC:

    AC.KickStarter.stateHandler.GatherObjects (true);

    That updates AC's internal record of what objects are in the scene and require updating.  This relies on Unity's FindObjectsOfType method, so disabled objects should be excluded.
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.