Make bullets shoot in right direction?

0 favourites
  • 8 posts
From the Asset Store
A shoot template with ragdoll effect and enemy see you.
  • Hi all,

    I'm new to Construct - had a hunt through forums and how tos but not found an answer to this - apologies if it's obvious. Feels like it should be...?

    I've started making a shooter with Zelda 4-direction style movement, i.e. not quite top down so have sprites/animations for each direction. So not using mouse or mouse angles etc for firing.

    Player shoots when space bar pressed. The bullets always go right and can't find a way of changing that. Tried to make it so bullet angle was set by what direction key was pressed (as that dictates which way player is facing) but then if you change direction after firing so does your bullet.

    Anyone know how I could solve this?

    Thanks all

  • I guess you are using something like

    on space-bar pressed create bullet at player position ?

    if so try changing it to

    on space bar pressed player spawn new sprite bullet.

    (spawn will create your new bullet at the players position and at the same angle as the player)

    I am also assuming you are using the bullet behaviour on the bullet ?

    Have a read through the beginners tutorials - nearly everything is covered there.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Using on space bar spawn new sprite.

    Because it's 4 direction and not truly top down 8 direction, like the Ghost Shooter in beginners guide, there's no player angle to use. It's more like an old school Zelda in terms of movement. (I tried to link to a URL to give an example but not allowed to yet.) Basically when you press a direction a new sprite/animation is loaded that corresponds to that direction. Not one sprite that rotates like in the Beginners Guide.

  • You can test what animation is currently playing and set bullet angle to that animation

    if "walk left" is playing set bullet anggle to 0

    if "walk down"... set to 90

    or you can name your animations to 0 - for walk left, 90 - for walk down... and then set bullet angle to animation name

    there's quite many ways to go with what you want to do.

    Best way is to put your capx file here and ask to look at it and help you with events you already have.

  • Okay, so lets say your animation frames for the directions are: 0 - right, 1 - down, 2 - left, 3 - up

    right after the bullet is created add an event for the bullet:

    Set angle of motion (or bullet angle? not sure here) = 90 * Sprite.AnimationFrame

    This way the bullet will go:

    Frame 0 -> 90 * 0 = 0, right direction of movement

    Frame 1 -> 90 * 1 = 90, down direction of movement

    Frame 2 -> 90 * 2 = 180, left direction of movement

    Frame 3 -> 90 * 3 = 270, up direction of movement

    Hope that helps :)

  • Thanks guys - this is all very helpful. I'm trying to use a tutorial I found on Direction-Based Sprite Animation to try and set the animations up properly in a way which records the angle of the player but it asks me to "add sub-event" and I can't find that in the menus.

    I right click on an event as the tutorial says but it's not there.

  • Found it - menus at the top. Sorry.

  • Can you provide a link to that tutorial you mentioned? That would be helpful to me too.

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