Stopping enemy animation upon overlap (ty Monitz87! + capx)

Get help using Construct 2

Post » Mon Jun 23, 2014 6:45 pm

Just want to say thanks to Monitz87 and everyone who has helped with my screwy problems so far. I'm having some new problems that I cannot find solutions for though, and I hope by posting the .capx, it will be easier to figure out.


This is a rough 'first person fighter', a little bit like Punch Out, but movement is like Dynamite Duke where you can pan the screen and both you and enemies can move. It has a working combo system and other features, but they are not included in this .capx for easier troubleshooting.

firstpersonfighter_capx.capx


If you play it, you'll see that the player's bounding box (player_bbox) and the enemy_bbox only move along the x axis, and that the enemy is always trying to overlap its box with the player's, at which point it will attack. Everything works well except that when the enemy's bbox does overlap the player's, the enemy's walking animation needs to stop immediately. It doesn't, in fact it continues to play through all of it's remaining frames of animation before attacking. You can see this happening by just moving away from the enemy a little bit and watching the enemy's walking animation frames (it's really clear in the debugger).


Any help would be appreciated! If I can get this working well enough, I will try to make the basic template and combo system available for everyone to use. Thanks in advance.
You do not have the required permissions to view the files attached to this post.
Last edited by Joy on Sun Jul 06, 2014 5:47 pm, edited 2 times in total.
B
4
Posts: 37
Reputation: 276

Post » Tue Jun 24, 2014 3:38 pm

Anyone? Please, I could really use some advice to try and fix this issue. I was checking tutorials half the night and couldn't find anything that helped.
B
4
Posts: 37
Reputation: 276

Post » Fri Jul 04, 2014 7:01 am

Sorry to ask again, but I've had to stop using Construct until I can get this problem solved. If anyone has any ideas, I'd really appreciate hearing them.
B
4
Posts: 37
Reputation: 276

Post » Fri Jul 04, 2014 7:22 am

It's not that the animation isn't stopping, it's just that your logic is somehow flawed and sets it to the "walkL" and "walkR" animations again when it shouldn't. Maybe you need a variable to track the overlapped state. Bit vague sorry, but see if that triggers any thought processes :) I've added a few log messages to show this.

firstperson_capx.capx


Edit: ok, so I thought I'd have a good go at this as I might learn something. See the capx below. It seems to be doing what you want.

firstpersonfighter_codah.capx
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Jul 05, 2014 2:33 am

Thank you very much for responding and for the capx. It does work, good job! (edit: oh, I guess not, sorry!) I'm not at all familiar with Browser commands though, in fact I had to get an extra plugin before your capx would even open here. Those commands will still function correctly if the game is packaged as a Node-Webkit, correct?
Last edited by Joy on Sat Jul 05, 2014 2:46 am, edited 1 time in total.
B
4
Posts: 37
Reputation: 276

Post » Sat Jul 05, 2014 2:45 am

I hate to say it, but it's actually not working properly; if you move away from the enemy once its entered the player's bounding box, it sometimes goes back into its walking animation and then freezes until the player moves back into range. I'm really surprised that something that would seem very simple is so difficult to implement.

I appreciate your help so far though!
B
4
Posts: 37
Reputation: 276

Post » Sat Jul 05, 2014 12:50 pm

In event 25, disable the action "enemy_bbox: Start ignoring 8Direction user input" and it works.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Jul 05, 2014 3:12 pm

Thank you, disabling that does stop it from freezing. However, it also causes the enemy to interrupt it's attack animation to pursue the player if you move out of range during an attack. It is important that the enemy's attack animations are not interrupted because it allows you to avoid attacks and then counter.

You should be able to see the enemy play out it's full attack animation even if you move the player bounding box out of the way during in the original capx. So far, I have not found a way to be able to interrupt the enemy's walking animation in order to attack, but force any attack animations to play through. No matter where I use "Stop Animation", it only seems to make the enemy freeze.
B
4
Posts: 37
Reputation: 276

Post » Sat Jul 05, 2014 11:42 pm

That's true. It is difficult to think some of these problems through. The event based nature of c2 is like concurrent programming in other languages and not easy to get your head around.

The thing I took away from working on your capx is to separate the changing of state variables from everything else. So set state variables in one event and act on those states in separate events. I can't help thinking that using Groups and enabling/disabling them to enable or disable certain events might work here. I'm looking into using that technique more myself. The are also state machine plugins which might be useful to you.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Jul 06, 2014 6:35 am

Why not program you own overlap detection by checking to see if the enemy object exists within an x-y range relative to the player? This can be achieved with 4 lines of code.

This worked for me in your capx.

Image

Cheers!

Dan
Image
B
36
S
14
G
11
Posts: 142
Reputation: 8,465

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, marcinkowski, Shenkai the ssj and 25 guests