Forum rules - please read before posting.

Custom action - Movement

Hi!
I created a 2D game with my custom controls, A (Left), D (Right), W (Jump), I also made animations by myself, and now I need the character to move on a marker using an action. I am not using any NavMesh.

I am a beginner at Adventure Creator, so I need a bit of advice. I would like to make an action, where you can assign a marker, and the player will walk there with animation.

Thank you.
Viktor

Comments

  • edited September 2019

    If the ActionList it's placed in blocks gameplay (which it will by default), then you can still use the Character: Move to point Action to control your character by giving AC control over the Player at this time. I'm assuming your Player script has his Motion control field set to Manual.

    The following code changes this field to Automatic whenever AC is in "cutscene" mode:

    private void OnEnable ()
    {
        AC.EventManager.OnEnterGameState += EnterGameState;
    }
    
    private void OnDisable ()
    {
        AC.EventManager.OnEnterGameState -= EnterGameState;
    }
    
    private void EnterGameState (GameState _gameState)
    {
        if (_gameState == GameState.Cutscene) KickStarter.player.motionControl = MotionControl.Automatic; // AC controls during cutscenes
        if (_gameState == GameState.Normal) KickStarter.player.motionControl = MotionControl.Manual; // Custom script controls during gameplay
    }
    

    Be sure to use the AC namespace by inserting "using AC;" a the top of your script.

    It may also be that you need to prevent your own script from updating the player's position during this time - to avoid a conflict with both systems trying to control him.

    You can limit your script's control over your player character to just during "AC gameplay" with the following check before updating his position:

    if (KickStarter.stateHandler.IsInGameplay ())
    {
        // Script updates position
    }
    

    To avoid pathfinding with the Action, uncheck it's Pathfind? field.

  • Thank you very much! I am glad, that this plugin has this forum!

  • @ChrisIceBox, also I am just wondering, should there be only one equal symbol, between KickStarted.player.motionControl == MotionControl.Automatic.

  • Doing well here, aren't I?

    Quite right - amended.

  • Also @ChrisIceBox, do you have a Discord? I need it.

  • A link to the community Discord channel is available on the right toolbar. For official support, please use the forum.

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.