Forum rules - please read before posting.

Checking object directions.

I have an character I would like to transform differently depending on what direction he is facing. Example would be if hes facing left he is moved +2 in the Z axis and if he facing left -2 in the Z axis. Is this possible without a custom script as I'm completely awful at scripting.

Thanks for any help?

Comments

  • edited August 2019

    If you're using "Sprites Unity Complex" animation engine for you character then a direction parameter is being automatically set.

    AC.KickStarter.player.GetAnimator().GetInteger("Direction");

    Note: The name of the parameter is being set in the NPC or Player script in the inspector and needs to be created in the character's animator.

    Another option is to use GetSpriteDirectionInt() function

    AC.KickStarter.player.GetSpriteDirectionInt();

    That gets the direction that a 2D character is facing (Down = 0, Left = 1, Right = 2, Up = 3, DownLeft = 4, DownRight = 5, UpLeft = 6, UpRight = 7)

    You can't get this information via ActionList as far as I'm aware. You can make your custon actions tho, there's a official tutorial.

  • Is this for a 2D game? AC won't move characters along the Z-axis normally, only X and Y.

    Likely some scripting would be necessary, but help can be given. I'm unsure exactly what you mean, however. If you can share more detail and screenshots it would help to explain the situation.

  • Another option would be to have a descriptive variable (pop-up switch perhaps) which changes everytime you change direction as the character. Then the variable could be checked to find out which way the character is facing.

  • Hey guys thanks for the response.

    Its using 2D sprites but in a 3D space. Its a side scroller so the character can only move in X and Y.

    Essentially I have an "Enemy" with trigger box attached as a child object looking for the player. When the Actionlist runs its has a QTE action where either the player or "Enemy" will attack.
    When either side attacks they are push backed and the impact animation is played but because they are sprites I cannot use root motion and instead rely on the transform action.
    I need to be able to detect what side the Player is facing to make sure the Transform is in the correct way and not pushing back into the player after a successful "punch"
    As it is at the moment I have duplicated a trigger on the other side of the character and given that the correct transform Actions. It works but leads to a double the amount of action lists needing to be managed.

    Come to think of it I could just use those two triggers to set a local variable and run a single action list to check for the variable and reset it after its done. A little fiddly but it may work.

  • You may want to look into applying forces to your Player's Rigidbody instead of manipulating the Transform, but that's a separate issue.

    To determine whether the player is to the left or right of the trigger, you may be able to use this custom Action on the AC wiki.

  • Thanks! thats super useful!

    Come to think of it your right because I'm likely to run into clipping issues. Ill have to look around for a solution as I don't think I can do that directly with AC.

  • I think I've solved the issue by calling an AddForce event with Playmaker. Looks like it should work!

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.