8 direction shooting problem [SOLVED]

Get help using Construct 2

Post » Fri Sep 08, 2017 10:05 pm

Hey guys!

So, in this game I'm making, the character will be able to shoot in 8 directions (like Samus does in Super Metroid). Only exception will be that, while on the ground, you won't be able to shoot down (only while jumping). So... you have 7 directions while on the floor and 8 directions while on the air.

Anyway, the system is pretty much done, the problem I'm having looks simple but It's really frustrating me since I've ran out of ideas of what might be causing it. The system works like this:

First, the aiming. I check what buttons are being pressed in order to know what direction the character is aiming towards. It goes like this:

Image
Image
Image

Baixo stands for Down and Cima equals Up. Code is in portuguese because I'm brazillian.

So, as you can see, I call a function with the direction parameter. All the function does is put the parameter value in a variable.

Image

Then I run a lot of checks (too much to show here) that checks the value of this variable and sets a value to the bullets that are shot. For example, DiagonalCima (or DiagonalUp) will make bullets go in angle 315 if not mirrored and 225 if mirrored.

These "mira" values (DiagonalCima, Normal, Cima, etc) are set into the character's animation so he swaps to the right one:

Image

That Else reads Set animation to Box.estado (the state the character is in, like Walk, Jump, Idle, etc) & the direction. So if you're aiming up while Idle, the animation that plays is Idle_Cima

So yeah I added animations for every state and for every possible direction the character can aim, with imagepoints on where the bullet is shot on each specific direction

The animation swapping is working fine. The problem is in the shooting...

When you press X to shoot, a function is called
Image

The function turns true a boolean, that will then do what it has to do

Image

The bullet is created succesfully, the bullet direction is set succesfully. The problem is that, they are not always created in the right image point. Specifically, when you're shooting diagonally up, if you suddenly stop moving horizontally sometimes the next bullet is sent up but on the diagonal imagepoint. You might be asking yourself why I created a function just to set a boolean true THEN for the shooting to happen, all this was an attempt to stop this problem. What is happening is that if I change shooting direction too quickly the animations don't swap quick enough and a bullet that goes up sometimes is created on the imagepoint of the diagonal up bullet.

I've messed with the events orders A LOT since I thought this had to be the cause. This is what it is right now:
Image

Here is a demo for you to see the problem:
https://marcosfuchter.itch.io/shooting8dir?secret=YZPRDtwbUOVA76RUbjvfuWGHbg

Try this: keep pressing X to shoot, then start messing with the Up and left keys (shooting diagonally up, and up). You'll see that a lot of times the bullet goes in the right direction, but is created on the wrong imagepoint!

Really sorry for the big post but, if you've read it all up to this point I hope you can help me. It was a really specific issue so I had to explain it all. Thank you very much!
Last edited by marcosfl on Sun Sep 10, 2017 3:04 am, edited 1 time in total.
B
20
S
7
Posts: 24
Reputation: 1,422

Post » Fri Sep 08, 2017 11:17 pm

Hey @marcosfl!

Not sure this is what you need, but...

https://www.dropbox.com/s/1xwrduwu0e18t ... .capx?dl=0

I hope this helps. Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 626
Reputation: 3,754

Post » Sun Sep 10, 2017 3:03 am

brunopalermo wrote:Hey @marcosfl!

Not sure this is what you need, but...

https://www.dropbox.com/s/1xwrduwu0e18t ... .capx?dl=0

I hope this helps. Cheers!


Before you replied, I dug deep in here and found what the problem was. Actually it wasn't on the system itself, but on the animations! If you're aiming diagonally, the character is moving, and if you suddenly stop pressing left or right you're aiming up, but the character still moves for a while due to deceleration! The problem was that I didn't have a "Walk_Up" animation, so it used the imagepoint of the previous animation (Walk_DiagonalUp) to shoot the bullet!

Thank you for the capx though! I'll study it and maybe do some tweaks on my programming :D
B
20
S
7
Posts: 24
Reputation: 1,422


Return to How do I....?

Who is online

Users browsing this forum: Bootfit and 29 guests