Forum rules - please read before posting.

Is there any way to check my player's direction in ActionList Editor in 2D adnvecture creator?

Hi, there!

Is there any way to check my player's direction in ActionList Editor in 2D adnvecture creator?

Something like [player] - [check] - current player ....

Because  I want to make my player's action look different depending on player's direction.

Like when my player's direction is _R, he do different action unlike _L.

I know that it is concern with GetSpriteDirection code...But I cannot understand how to use a custom script in ActionList Editor.

Please help me. Adventure creator is awesome.


  • You can use GetSpriteDirectionInt ():

    int currentDirection = AC.KickStarter.player.GetSpriteDirectionInt ();

    See the scripting guide link above for what direction the return value refers to.

    Custom scripts can be added as Actions following the steps in this tutorial.

    However, this may not be necessary.  When using the "Character: Animate" Action with the method "Play Custom", you have the option to "Add directional suffix?", which will add e.g. "_L" to the clip name you enter dynamically when run.

    Also if you use the if you use "Sprites Unity Complex" as your player's animation engine, your "facing direction" is set to a parameter value - meaning you can use that to wire up your Animator Controller differently for different directions.
  • edited October 2022

    Hi, I'm also in need to get the direction of the player. I'm trying to follow the custom actions tutorial, but being totally ignorant of c# and unity's architecture, I'm having some difficulties. While my custom action appears correctly in the AL, I suspect the code doesn't get executed at all. I'm still trying to copy the example, and gravity doesn't seem to be affected at all when the AL is run (since I'm working in 2d I'm expecting the affected character to fall off the screen like if I disable "ignore gravity"). Also as a test I tried to add an absurd value for the return (return 99999f) but the action seems to be just over and done immediately, with no delay.

    Also I found that in the tutorial there's this line I'm supposed to change:

    public class ActionTemplate : Action

    into this:

    public ActionGravity : Action

    the thing is, if I lose the "class" Unity will throw an error (also the IDE won't highlight the rest of the line so I guess there's just something wrong with the syntax). so I kept the "class" but I'm not sure if I'm supposed to

    Lastly, my ultimate goal is to write the direction integer into a variable accessible from the AL. I guess I'll need to add a public property that will show in the GUI and that will accept global/local AC variables. Even if I get the example action to run correctly, I have no idea how to write the int "currentDirection" into an AC variable

    I understand this not supposed to be a scripting support forum, so I apologize if this isn't allowed.

  • The removal of "class" is a typo! Thanks for pointing it out - I'll amend it.

    Here's a custom Action, ActionTransferDirection.cs, that can be used to pass the direction integer to a Global Integer variable:

    using UnityEngine;
    using UnityEditor;
    namespace AC
        public class ActionTransferDirection : Action
            public override ActionCategory Category { get { return ActionCategory.Player; }}
            public override string Title { get { return "Direction to variable"; }}
            public string variableName;
            public override float Run ()
                int directionInt = KickStarter.player.GetSpriteDirectionInt ();
                GlobalVariables.GetVariable (variableName).IntegerValue = directionInt;
                return 0f;
            #if UNITY_EDITOR
            public override void ShowGUI ()
                variableName = EditorGUILayout.TextField ("Global Int variable:", variableName);
  • Awesome, thank you so much! this saved my week

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.