imagepoints and rapidfire

Get help using Construct 2

Post » Mon Oct 14, 2013 1:15 am

This is kinda complex so I'll be as specific as I can.

My game is in "CONTRA" style.
The character is divided in 3 sprites: legs, upper half, and shooting animations.

the legs are the main part and are separated form the rest so i don't have trouble with the "firing/walking" animation.

the upperhalf is pinned to the legs and when you aim that's the part that switches anims so it aims correctly at every direction.

and the shooting is just the frames of the upper part while the guy shoots, also pinned to the legs. when these appear, the other upper half goes invisible, so it looks like both are the same sprite and it doesn't interfere with the aiming. When the guy is not shooting, this sprite goes to a "null" animation that has no frames in it, an invisible animation.

We're Ok so far.

Now I'm creating a machinegun alternate mode.

I've made it this way:

When "Z" key is down, the shooting sprite goes to the normal shooting. when it ends, it goes to the null anim, and if when the null anim is over the key is still down it goes again to the shooting.

so it creates a loop that stops once you've released the key.

the thing is working perfectly, but the problem is that the bullets are coming from the imagepoint of the NULL anim, not the SHOOTING anim. So, it is like if the bullets are being created 1 tick before it should and are interpreting the imagepoints of the previous anim. This is weird since it's set so the bullet is created once the shooting anim starts, so, there's no way the bullet is created before.

It works fine in the first shoot of the bunch, but when it gets in the loop is where the problem starts.

How can I solve this?Borghi2013-10-14 01:16:18
B
5
S
1
Posts: 92
Reputation: 609

Post » Mon Oct 14, 2013 7:23 am

I don't know how you have your events and conditions set up, but I do have some questions.

Why use the null animation instead of setting the sprite invisible?

Have you tried the, system wait : 0, anywhere to wait 1 tick before progressing?

Is it possible to set the imagepoint for the null animation on the spot you need for the shooting?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Oct 14, 2013 7:28 am

Not sure if this will help, but I have an SMG with 2 frames animated. Basically one frame for the shot, and another for recoil. SO I have my bullet scripted to spawn every time the "fire" frame is played.

When frame(fire) plays,

spawn bullet;
trigger once;
play sound;
etc.
B
7
S
2
G
2
Posts: 14
Reputation: 1,626

Post » Mon Oct 14, 2013 3:43 pm

[QUOTE=LittleStain] I don't know how you have your events and conditions set up, but I do have some questions.

Why use the null animation instead of setting the sprite invisible?

Have you tried the, system wait : 0, anywhere to wait 1 tick before progressing?

Is it possible to set the imagepoint for the null animation on the spot you need for the shooting?
[/QUOTE]

well, I used the null anim so I can use the time of the anim as the space betewwn shoot and shoot, besides, the srpite needs an animation to fall into when not shooting.

about the wait, I've never used it yet. I'll check how it works.

I can set the image point in the null where I want, but that would bring this problem:

With the shooting srpite being a separated thing, the main sprite can aim freely all the time. So, if you are aiming forward, fall into the null, and then the pleyer aim upwards, the shoot would again interpret the imagepoints of the null, shooting forward. so, it's imposible to predict where the player will aim.

Going back to the main problem, it's really weird that what I'm doing is playing the same event over and over but once the second shoot starts that strange thing happens. I mean, it's the same event, should work exactly the same.
B
5
S
1
Posts: 92
Reputation: 609

Post » Mon Oct 14, 2013 4:50 pm

I still don't see why you'd need a null animation but ok..

you could just check if your firing animation is playing before spawning bullets. you could even check what frame it's on and spawn bullets on a specifivc frame.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Oct 14, 2013 9:59 pm

[QUOTE=LittleStain] I still don't see why you'd need a null animation but ok..

you could just check if your firing animation is playing before spawning bullets. you could even check what frame it's on and spawn bullets on a specifivc frame.[/QUOTE]

how can I check that?

My firing animation has only 1 frame, so, I guess that's the frame.
B
5
S
1
Posts: 92
Reputation: 609

Post » Mon Oct 14, 2013 10:11 pm

add a condition

sprite is playing animation
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Oct 14, 2013 10:19 pm

that's set.

bullet is only created when the sprite is in the firing animation and is triggered once.

That's the weird part: how can it check the previous imagepoints if the bullet isn't created in that moment and only appears once the correct animation is playing?
B
5
S
1
Posts: 92
Reputation: 609

Post » Tue Oct 15, 2013 5:28 am

OK!
Here I uploaded the capx:

https://mega.co.nz/#!HRtXlBJK!SyvwSBpeYuULlxkIU5u0CBrY9GAkHu2xBoDrlhqOJYQ

it's big! but that's cause the character is big, since I plan to do some serious zooming later.

X shoots, Z jumps, and CTRL holds your position while shooting.

pressing 1 or 2 will alternate the fire mode from rifle (1) to machine gun (2).

the problem is when shooting on machinegun mode in rapid fire. For the moment is only implemented in the stand/idle shooting.

B
5
S
1
Posts: 92
Reputation: 609


Return to How do I....?

Who is online

Users browsing this forum: jatin1726 and 31 guests