Forum rules - please read before posting.

2D Direct Controls With Only 2 Facing Directions

Hello!

I've been building a 2D game with Adventure Creator pretty smoothly for the past few months, but I've ran into one issue I'm beginning to think won't have an easy solution outside of adding some custom script and using Unity's base engine to work around the problem, but if there happens to be a solution directly in Adventure Creator Id love to continue using the plugin as much as possible to avoid the extra time it might take to get the same result.

As the title describes, I'm using the "Direct Controls" method for a 2D game that is supposed to have only 2 facing directions (Left and Right) but there's 1 glaring issue whenever the character is moved down or up. Since there are no down or up facing sprite animations the character will default to the left if you are moving vertically. This in itself isn't a huge problem, but it definitely looks a bit awkward.

This problem is very similar to what was happening in this thread here.

https://adventurecreator.org/forum/discussion/2414/2d-character-without-up-and-down-animations-is-walking-backwards

I've followed this thread and tried a few different methods, including the solutions presented within this thread to try and get an animation that works as described below:

_If the player is facing to the left and they move up or down they will continue to face the left, playing only left idle and left walking animations until the player hits the right button. (This works fine since it defaults to left anyways)

If the player is facing to the right and they move up or down they will continue to face the right, playing only right idle and right walking animations until the player uses the left button. _

Following the thread I shared above, I could see how using angles for a point and click game would solve this issue but I'm having trouble grasping exactly how to apply it for Direct Controls and I'm beginning to think Adventure Creator might not be able to in the way I'm imagining it.
That being said my experience with Unity is a bit limited, I've been getting used to the software and have gotten pretty far using Adventure Creator so it's kind of my crutch at the moment so having issues trying to create something like this could just come down to my lack of understanding and might just need a little more trial and error.

Just a little more info on my understanding of why this might not be working-

Using Sprites Unity Complex I can recreate the same sprite animations with ease using the parameters and conditions. Using Angles &/or Directions

But using this method only creates the same issue where moving up and down causes the player to look left regardless of which direction the player was last facing.

If I press Left my direction changes to 1

If I press Right my direction changes to 2 and that's perfect!

but If I press Up or down my direction changes back to 1 so naturally it will default back to the left If I have the parameters set up to do so. If I add more directions then I can add new sprites but the whole point of this discussion is to put in place a system that works with only 2 facing directions.

For a little more information this is kind of what the game looks like.

And here's the problem I'm talking about in action

(I'm only pressing up and down here without any interaction with the left input)

The player character can move up and down, left and right in the environment just fine but I only want left and right facing directions in the game regardless if the player is moving vertically or horizontally.
For even more clarity I can compare the movement system to similar games like castle crashers where there is some vertical movement but the character's sprites always face to the left or the right without needing two additional sprite angles for up and down. If there is a proper way to recreate that type of movement system in Adventure Creator please let me know! If not I can try to figure it out myself or search up guides on how to recreate that outside of Adventure Creator's system.

If you need any more images or additional information just let me know! I appreciate any help you can give me.

Comments

  • Quick solution for me right now is to just assign down as another facing left animation & assign up as facing right... it's not exactly what I'm looking for but it looks a little more natural to me for movement. I've skimmed through other topics here to see if there's any way to recreate the type of movement I'm looking for but no luck! If anyone has some ideas please let me know! Thankyou for your time!

  • I FOUND MY SOLUTION!

    It took a little time for my puny brain to understand what I was doing wrong (pretty easy fix) but I got the result I was looking for with a little bit of thought put into it... the solution was actually a lot easier than I expected, I was pretty certain getting the result I was looking for was possible.

    For anyone else that might be using Adventure creator for a 2D game with only 2 facing directions where you can still move up and down here's how I set things up for the type of movement I wanted.

    Start with ANY STATE and one of your idle positions set as the default.
    Add speed conditions to both the left and right walking animations as well as direction conditions to transition between one or the other facing direction (1 for left, 2 for right for me in this example)

    Then branch off your transitions to your Idle positions giving them a condition of less than 0.1 speed. Left Walk will transition into Left Idle, and Right Walk will transition to Right Idle.

    Copy your walking animation and then add 2 more transitions that go to the 2nd walking animation and back to the previous idle position. Greater speed of 0.1 should transition the animation back to the walking pose, less speed of 0.1 should transition it back to the idle resting animation.

    And that's how I got the movement I wanted.

    I'm sure it's probably an easier solution than I made it out to be but just in case there's someone else out there that might be trying to replicate this type of movement that's how I put it all together!

    Make sure your using Sprites Unity Complex for the Animation engine, and set up your parameters in the Animator.

  • edited November 2019

    Welcome to the community, @Fleppyflepster.

    As things are now working for you, perhaps it's best to leave things as they are.

    Going back to your original solution (using the "Angle" parameter to change animation), the issue was likely due to the the transitions being overly sensitive. That is, if the Angle is exactly 180, it's not clear exactly what animation should play.

    Perhaps this method might have better results if you instead rely on directional angles, so that e.g. left-facing animations only play if facing from SW to NW (on a compass), and right-facing if NE to SE. If the character is facing from NW to NE, or SE to SW, then no transition is valid and the animation it's currently playing should continue.

  • @ChrisIceBox Thankyou for the warm welcome! I really appreciate it!

    After I fixed my problem I wanted to delete this post but if there happens to be another user that stumbles into a similar issue I figure keeping this up is probably a better idea, especially if someone's looking to create a similar type of game with this setup!

  • @ChrisIceBox heya! sorry to bring up such an old thread but I'm having this same issue here and I'm wondering if there is a better solution made since this thread. I cannot use fleppy's solution since my animator setup is slightly different. I'm basically using a separate animator layer for direction so that it flips everything no matter what other animation is playing on other layers (talking/idle/run).

  • In the Manual I actually found this script: https://adventure-creator.fandom.com/wiki/Frame-flipping_for_Sprites_Unity_Complex_characters Actually pretty nice since it saves me from needing that direction layer in the animator but still has the unfortunate effect of 180 always being left and 0 always being right. Can't figure out a way to just have 180 and 0 be totally ignored so they are whatever direction the character was already facing.

  • Can't figure out a way to just have 180 and 0 be totally ignored so they are whatever direction the character was already facing.

    You raise a good point - I've updated the script with a "Top Angle Freedom" Inspector field that should address this. Give it a try and see if it helps.

  • Really appreciate the quick response and script edit, but I seem to still have the same issue. The only time the angle freedom stops the swap on up and down is if it's over 90 (which then stops the swap altogether)

    https://drive.google.com/file/d/1PrzozU79CJazknBzjiyhXji38dI9qOXu/view?usp=sharing

  • edited January 2021

    I found the issue. In settings I had "Turn instantly when under the player control?" toggled OFF. Which was not only giving a weird drift when going in just two directions but was causing that direction to change sometimes like in that gif I shared above. Simply checking that ON fixes both.

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.