Throwing an object in 8 directional interface

0 favourites
  • 4 posts
From the Asset Store
Throw daggers and hit the most fruit! Watch out for the wind, if you run out of daggers you'll lose the game!
  • Hi

    I'm looking for a way to throw an object a "grenade" for example in 8 directional , I searched the forum but didn't find anything could help.

    All i found is using physics, and I'm not sure it's gonna work in my case.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could be more specific about what you want. What type of game is this? Is it platformer, top down shooter or what?

    Without more specific info, we could not provide anything useful for you.

  • Hi

    It's a top view shooter.

  • 8 directional top down shooter? You could extend from the Ghost Shooter sample, but then you need to clarify further: how and what will set the angle of your grenade?

    The how part is : in your event sheet, you can, for instance,

    • if key spacebar is pressed:
    • - create a grenade at player's object
    • - set angle of grenade to ____ angle.

    The blank above is the what part. What should be the angle of your grenade? Should we set it accordingly when the player is holding the directional arrows?

    If that's the case, extending from above, you could have a global variable and some more keyboard related events like this:

    Global variable grenadeAngle = 0

    (Right click somewhere NOT on your events IN your event sheet and you should see an option to create a global variable)

    • if key left is being holded:
    • - if key up is being holded:
    • - - set global variable grenadeAngle to -135.
    • - else if key down is holded:
    • - - set global variable grenadeAngle to 135.
    • - else
    • - - set global variable grenadeAngle to 180.
    • else if key right is being holded:
    • - if key up is being holded:
    • - - set global variable grenadeAngle to -45.
    • - else if key down is holded:
    • - - set global variable grenadeAngle to 45.
    • - else
    • - - set global variable grenadeAngle to 0.
    • else if key up is being holded:
    • - set global variable grenadeAngle to -90.
    • else if key down is being holded:
    • - set global variable grenadeAngle to 90.
    • if key spacebar is pressed:
    • - create a grenade at player's object
    • - set angle of grenade to grenadeAngle angle.

    Make sure you put the spacebar event below the left right up down business. Because events from top to bottom. This will allow your grenadeAngle to reflect your recent input in this tick right away.

    So what did we just do from above? We set the variable grenadeAngle to respective key inputs. If you don't understand what the heck did I just write above, you may wish to google if else statement in programming.

    (If any of the term feels confusing or you need more assistance, please say so and add my name "@keroberos" in your next reply)

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