How do I make it play an animation whilst pressing two keys at the same time?

0 favourites
  • 10 posts
From the Asset Store
Piano Keys
$1.60 USD
60% off
A musical typing game where the goal is to play a song by pressing the matching keys as fast as you can!
  • Probably a pretty easy concept, I just can't really figure it out.

    I want my player to play an animation when two keys are pressed (at the same time).

  • 'Key is down', 2 conditions together acts as an AND.

  • Doesn't work, I've probably done it wrong.

  • Is your animation named correctly?

    Is it in the correct object?

    Is the animation speed something besides 0?

    Is your event sheet linked to the correct layout?

  • Is your animation named correctly?

    Is it in the correct object?

    Is the animation speed something besides 0?

    Is your event sheet linked to the correct layout?

    Extremely late reply, But, I still haven't figured it out. Everything is exactly as you said.

  • It works... Unless you've got a keyboard that can't have s and d pressed at the same time, which is extremely unlikely but not impossible. Is your animation set to looping?

    You're probably going to need to upload your project to see what's wrong with it.

  • It works... Unless you've got a keyboard that can't have s and d pressed at the same time, which is extremely unlikely but not impossible. Is your animation set to looping?

    You're probably going to need to upload your project to see what's wrong with it.

    Here you go.

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm actually not sure what's happening here. There's some conflict with your other animation events. If you disable the walk right event it works fine, but I'm not seeing why at first glance... Will check it out some more later, or someone more familiar with animating 8 direction would probably know.

  • Looks like common practice for animating diagonal directions is to set animations based on angle of movement, rather than inputs.

    Edit: Setting an instance variable, and changing the animation only once per tick based on that variable also seems to work, like so:

    + Keyboard: ↑ is down
    -> Sprite: Set anim to "up"
    
    + Keyboard: ↓ is down
    -> Sprite: Set anim to "down"
    
    + Keyboard: ← is down
    -> Sprite: Set anim to "left"
    
    + Keyboard: → is down
    -> Sprite: Set anim to "right"
    
    + Keyboard: ↑ is down
    + Keyboard: ← is down
    -> Sprite: Set anim to "upleft"
    
    + Keyboard: ↑ is down
    + Keyboard: → is down
    -> Sprite: Set anim to "upright"
    
    + Keyboard: ↓ is down
    + Keyboard: ← is down
    -> Sprite: Set anim to "downleft"
    
    + Keyboard: ↓ is down
    + Keyboard: → is down
    -> Sprite: Set anim to "downright"
    
    + Keyboard: ↑ is down
    + OR Keyboard: ↓ is down
    + OR Keyboard: ← is down
    + OR Keyboard: → is down
    -> Sprite: Set animation to Sprite.anim (play from beginning)
    
    + System: Else
    -> Sprite: Set animation to "idle" (play from beginning)
    
  • Sorry for the late response, but even with this explanation, I still don't understand, could you explain in more detail?

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