Trying to implement "if A or (B and C)"

0 favourites
  • 3 posts
From the Asset Store
You are a fisherman who is trying to catch some fish in the ocean.
  • I'm essentially trying to implement "if A or (B and C)" condition logic for my player's shooting. Normally the player must press the z button to shoot a single bullet, but if they've purchased a 'rapid fire' upgrade, they can just hold down the z button and they will continue to shoot.

    I'd like to implement the logic like this:

    if (z button pressed) OR (z button down AND player.hasRapidFire = true) then [execute shoot logic]

    However, I can't do this because C3 doesn't allow combining AND's and OR's in a single event. And because [execute shoot logic] is rather complicated, I don't want to duplicate it in a separate event or put it into a function.

    Can someone please suggest a clean way to implement this condition logic?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use a variable for gun state.

    State = 0 => on key Z pressed

    State = 1 => on key Z down

    ...etc.

  • I like your suggestion, it's clean and it works. Here's how it looks in code fyi. Thanks!

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