2D Side Scroll Shooter Help

This forum is currently in read-only mode.
From the Asset Store
Cannon Ball Shooter game assets for 2D bubble shooter puzzle game.
  • Hello,

    I'm trying to make a metroid-like game, but I'm having a problem. I want to make the shooting so that there is no bullet to be seen. Basically I want the player to see explosions coming from the barrel and a ricochet effect coming from whatever is in front of the player. I can't seem to find a solution on how to detect what is in front of the player and where to spawn the ricochet effect. Here's the effect I want:

    Any idea how I would go about detecting what is in front of the player depending on orientation?

    I also have another issue which is the blast coming from the barrel. The blast doesn't follow the player. When you first press fire it appears at the player but if you continue to hold and walk around it stays in the same spot. Any help with this?

    Sorry if I'm sounding newbish, but I'm just new to Construct.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is what loops are for.

    You'll still need an object to collide with the wall, but you'll simply make it invisible. You'll spawn a bullet object at the end of the gun object, and run a loop that iterates the bullet's position across space until it finds a collision. Loops run within a step instead of once every step, so it will not continue any other code until that loop is done, and the iteration ensures contact, so the bullet movement is instantaneous without concern of it overlapping too far or phasing through other objects.

    Basically, you would use a while loop condition. The loop is run while the bullet is not overlapping anything. The actions in the loop should move the bullet forward one or more pixels ahead (the farther this distance, the less iterations the loop will have to run as the bullet will make contact that much faster, so keep that in mind). In an else condition, add a break loop action, destroy the bullet and create the spark effect.

    Be mindful of while loops, as they will run forever until a condition is satisfied. Make sure your environment is air tight, or create an escape condition such as breaking the loop or destroying the bullet after it has traveled a certain distance.

  • Thanks a ton! I will definitely have to try this. Yea I figure I'll make it so that if the bullet goes off camera then the bullet is destroyed. In other words, you can't shoot things off screen which I'm fine with.

  • For the blast following the player couldn't you use the action, Set position to Player after checking the angle?

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