Forum rules - please read before posting.

Small edits/additional variable existence checks

Hey, I've recently updated to the latest Adventure Creator and merged it with my internal edits. I'll place a couple of feature requests/small edits, that are mostly for additional error avoidance when missing elements or small passing down of some parameters:

1. RuntimeVariables.cs, AssignFromPreset method. Inside the foreach loop the when AssignFromPresets is called recursively ignoreOptionLinked variable is not passed down deeper.

2. NavMeshAgentIntegration.cs at the end of SetCharacterPosition, check whether the character isOnNavmesh before setting destination.

3. Sound.cs IsPlaying method. Check whether audioSource is null or not. This can error-up if the gameObject starts off disabled and doesnt get enabled before something asks if the sound IsPlaying, since if the gameobject never got enabled the awake wasnt called. The handling of such situation could either be calling the awake manually and adding a bool which checks if the awake was already called, so that you don't accidentely execute it twice or simply returning false if audioSource == null.

Thanks for your time.

Comments

  • Thank you for yours!

    1. I think I see what you mean - nothing broken, just a performance improvement, right?

    2. Isn't Unity's NavMeshAgent built to cope with this?  What would happen if the character is not on the NavMesh?

    3. Yes, that's a fair point.
  • 1. Nope. Since the default of ignoreOptionLinked is set to false and it is not passed down deeper, even when you set it to true while executing an actionlist that calls this method, it defaults to false eventually and not all option linked variables get ignored. I'll pm about this.

    2. It may throw an error: ""SetDestination" can only be called on an active agent that has been placed on a NavMesh.". 'May throw' because unity is sort of weird if the agent is close to navmesh it might snap to it, if it's further away the error gets thrown.
     
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.