Crawling (And other animations that require 2 keys)

0 favourites
  • 5 posts
From the Asset Store
Piano Keys
$3.99 USD
A musical typing game where the goal is to play a song by pressing the matching keys as fast as you can!
  • Very simple question, sorry about this.

    I've got a character who can crouch, but I'm a little confused about how to get her to crawl.

    Here's my events sheet so far, sorry if it's a little unorganized/unusual, this is my first level:

    But yeah, basically I'm unsure about where to start really, how do I make my character use it's "crawl" animation when moving left/right if I'm holding the 'down' key?

  • Hi. I'm very new to Construct 2 so sorry if mine isn't the best solution, hopefully somebody with more experience will come along and help with your query or vouch for my solution.

    From my point of view an easy way to do this would be to make an instance variable called "Crawl". Just set it to 1 when the down arrow is pressed and then you can call on the animation group that relies on "Crawl" being set to 1. All other animations would play when "Crawl" is set to 0. You can add a condition that states that the character must be on the floor to avoid weird instances of the player crouching in mid air...unless you want to allow that for whatever reason.

    On a separate note I'm a bit confused why you used "On Down arrow pressed" to start crouching instead of "On Down arrow is down". The former would make it so when you let go of the down key the character would still be crouching but the later would stop the crouch as soon as the key is released (which is what I assume you want to do based on the very last event). Then again maybe you tried that already and something went terribly wrong.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks very much for your response!

    It sounds super helpful... however, when it comes to visual scripting (or any kind of scripting really), I usually find myself asking some very basic questions, I hope you don't mind!

    Firstly, in regards to making an instance variable, how do you mean? I thought in Construct 2 instance variables needed to be made from a sprite or object in the layout. I know I can make a Global Variable in the even sheet, but I was not aware I could make an instance without an object. Honestly I assumed I'd need to do something like this, however I'm just not sure how.

    On the separate note, my event sheet will be riddled with mistakes, as this is my first construct 2 file... I know that's quite the lazy excuse, but I'll be sure to clean it up, thanks for pointing it out!

  • You're right about the variables.

    Just add an instance variable to "CharacterCollision" and call it whatever you prefer. Set it to numerical since from what I've seen boolean seems a bit lacking (or I just got unlucky and it didn't work well for me). Replace your crouching event with one that states "When Platform is on floor" and "When down key is down" and use the actions you already have (the animation and size changes). On top of those also add an action that sets your instance variable to 1. Then add a sub event that makes the character stand up, for example when pressing the down key again, and set your variable to 0.

    For all actions that the player should only be able to do when crouching put a condition "When Variable (whatever you called it) = 1"

    For all actions that the player should only be able to do when standing put a condition "When Variable = 0"

    This will prevent any weird instances of conflicting actions. For example, your character jumping while crouched.

  • Thanks again for your reply, you're really helping me out here!

    I only just realised that you can have multiple conditions for a single event thanks to you, so that's a huge help.

    The crouching works fine now! As does the crawling! There's a few problems so far though, the biggest being that I can't seem to be able to get back up once I'm down... probly another stupidly easy to solve situation, but here's my event sheet:

    Sorry if it's a little confusing (I didn't think ahead here), but the boldened Crawl, and the Crawl in quotations are a variable and an animation, respectively (Something I'll change later, for sure).

    26 = Enter crouch mode

    27 = Exit crouch mode (back to Idle)

    28 = Crawl when in crouch mode

    29 = Exit Crawl mode (back to crouch)

    30 = Can't jump when in crouch mode

    Thanks again!

    EDIT: I've managed to get it working the way I want it. Again, thanks to JudgementXD for all the help!

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