How do I set IDLE animations for when player stops moving? 8 direction behaviour (Diagonal also)

1 favourites
  • 9 posts
From the Asset Store
Rotate & Animation for 16 Direction & Mouse Direction
  • I'm moving my player character using the pin and 8 direction behaviour method. Default controls are off so the keys 'W A S D' are in use. My animations are working when the player is moving in any direction (diagonally as well) but I want him to be facing the direction he was walking in before he stops, using one of my Idle animations.

    In addition I've INVERTED the event '8 direction is moving' with the player action being 'set animation' to my default idle, meaning when the player stops moving the same Idle_SE animation plays, regardless of which direction he was moving. I have a feeling this is causing the complication. But if this event was disabled then the walking animations would play when hes not moving at all (since they're looped).

    I have all the Idle animations ready for each direction in the animations editor. I tried doing 2 keys released (W and D for up_right_diagonal) for it to the play specific Idle animation but it didn't work.

    Would I have to use variables? If so how would I go about this? I'm fairly new to Construct 3

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sounds like you know what you're doing but key release is problematic there. I would do it on key press rather than release. Set up logic such as, if W pressed set variable to 1, if D pressed set variable to 2. If W AND D pressed set variable to 3 etc

    Then you have your current logic inverted 8 direction is moving, set animation to "variable" where variable could also be the name of the animation to cut down on events. For example if you called them idle1 idle2 idle3 you could say set animation to "idle"&variable

  • Ive assigned EACH Key is Down event (W A S D) with its own local variable for example;

    Local number Walk_ Up = 1

    Keyboard w is down | Player (sprite) | Simulate 8Direction pressing Up

    Direction (pinned sprite)| Simulate 8Direction pressing Up

    ------------------------------------------------------------------------------------------------------

    Local number Walk_Right = 2

    Keyboard D is down | Player (sprite) | Simulate 8Direction pressing Right

    Direction (pinned sprite)| Simulate 8Direction pressing Right

    ------------------------------------------------------------------------------------------------------

    ...etc.

    How would I go about making one variable out of both W AND D pressed? And how would my 'Inverted 8Dir Movement' event know when the 'W and D' variable has finished (keys released) in order to play Idle_Up_Right animation

  • It knows when the keys are released because your logic says when 8 direction is not moving then set the animation to an idle animation. Because you just released for example W then you character will want to face up so it will play the up animation and it will have a variable set related to when W was down.

    For the key logic you do something like :

    W is down - set variable to 1

    D is down - set variable to 3

    W is down AND D is down - set variable to 2

    You do an AND by adding both conditions together on the same event

    Use a global variable, not a local variable.

    The idea is when you release a key, the last key or keys that were down will have produced a variable. If you were holding W(up) and released then the variable will be 1 etc. That variable then relates to an animation.

  • I'm almost there I think, your explanations are very clear. Although I'm missing something or could be doing it completely wrong. I'm stuck at the inverted 8Direction is moving event, not sure how to apply the global variables with animations.

    Also I'm not sure whether to make a global variable for EACH key is down or to have one global variable with different number values for EACH key is down event. (I'm still trying to get to grips with variables logic i'm fairly new to construct 3.

    Ive uploaded an image of my event sheet if you could take a look at please. If you can tell me what I'm doing wrong or what i need to do that would brilliant.

    ibb.co/80c15Zs - image of event sheet

  • There's a few problems there so I'll try and explain without it being too confusing. I went with the variable method because I don't like the angle logic but it looks like you are using angle so maybe it's ok to use this instead (assuming the walk animations are correct for you).

    The main problem is those angle conditions for walk animations are running all the time so you won't be able to set an idle animation. They need to be 'sub events' but are currently just listed underneath as separate events which doesn't mean sub events in construct. You need to press S and add them so they are indented under 8 direction is moving event. That was maybe your problem from the start.

    So ignore the variable logic I mentioned, when you have fixed it so those angle checks are sub events/indented on the 8 direction is moving logic, all you need to do is copy and paste those events, change 8 direction is moving to inverted, and change your animations to the idle ones.

  • DONE IT! It was the simplest method the whole time. It was the sub events that did it and of course the second of the two '8Dir is moving' events (Inverted one).

    Thank you! You're a huge help :)

    One more thing:

    I know its RARE that both keys are naturally released at exactly the same time, but I would like to see more of my DIAGONAL Idles animations when the player stops moving diagonally, instead of him most of the time facing either N,W,S,E. (Due to a key being released a millisecond earlier for eg.)

    Is there any way of balancing out the 8 idle animations I have for the player to see, instead of it playing (most of the time) the up, down and side idle animations. Not seeing enough diagonal idles basically.

    Its me being picky but I hope you understand. Achieving my intentions with this is probably a long shot but i hope not. I'm sure pretty much anything can be done on construct and I want my game movement to be great

  • Hmm not totally sure because the 8-direction behaviour moves in 8 directions but when you stop it snaps to 4 directions. Since you are using angle you could try setting angle for the sprite based on keys being pressed and making your own movement to accomplish this instead of that behaviour.

  • Ah that's what I thought. Makes sense. Cheers

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)