Forum rules - please read before posting.

Using Bolt/Unity Visual Scripting alongside AC with pausing and ect.?

edited July 2021 in Technical Q&A

I've seen that there is a script for making Bolt/Visual Scripting variables readable by Adventure Creator. But, let's say I were to create an enemy AI and damage system using Bolt. How would I make those elements able to be paused by Adventure Creator's system when everything else pauses?

I've only been using AC for a couple of days now, and I'm just wondering what the optimal ways to manage stuff like this are before I get too deep into a project. And I'm still getting used to how everything works in AC as a system.

Thanks in advance!

Comments

  • Welcome to the community, @DedicatedGhost.

    You can determine whether or not you're in a cutscene at any time using:

    AC.KickStarter.stateHandler.IsInCutscene ();
    

    And if the game is paused with:

    AC.KickStarter.stateHandler.IsPaused ();
    

    See the front page of the Scripting Guide for links and more examples.

    You can either check this each frame, or hook into AC's OnEnterGameState event to only update on the frame that the state of the game changes, i.e.:

    using UnityEngine;
    using AC;
    
    public class GameStateEventExample : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnEnterGameState += EnterGameState; }
        private void OnDisable () { EventManager.OnEnterGameState -= EnterGameState; }
    
        private void EnterGameState (GameState _gameState)
        {
            if (_gameState == GameState.Normal) Debug.Log ("In normal gameplay");
            else if (_gameState == GameState.Normal) Debug.Log ("Paused");
            else Debug.Log ("Now in a cutscene");
        }
    
    }
    

    See the Manual's "Custom events" chapter for more on this technique.

    You could use this to e.g. set a Bolt Bool variable that is True whenever in a cutscene, which you can then incorporate into your Bolt systems:

    using UnityEngine;
    
    public class BoltCutsceneSetter : MonoBehaviour
    {
    
        private void Update ()
        {
            Bolt.Variables.Application.Set ("IsInCutscene", AC.KickStarter.stateHandler.IsInCutscene ());
        }
    
    }
    

    For a general overview on incorporating other systems/scripts into AC, see the Manual's "Integrating new code" section.

  • Thanks a bunch Chris! I'll be sure to reference this when it's time to integrate things. :)

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.