A few issues on attack animation and enemy behaviour

Get help using Construct 2

Post » Mon Apr 07, 2014 6:08 am

I mean how you have the box for the player, then the player's sprite? Add another box that's attached to an image point where it's always in front of the player. This makes it SO much easier for detecting direction.

As for animations, you need to make sure the event "animation idle is NOT playing" etc to ensure your animations are in tact. Idle should be the lower most point of animations. Imagine the "idle" animation as if it were a rubber band. any new animation playing is like popping that rubber band, but it HAS to be back in place when it's over. Computers don't know to put things the way they were, just the last way you told them. So if you tell it "it should be this way" then you have it do something else, make sure "that way" isn't active, and when the new way is done, ensure the old way is back in place.

It's so hard to explain, which is why I'm not a teacher, but it works in my mind to think of animation and game states as rubber bands that get popped here and there, but after the popping is done it goes back to a general state (ie: idle, health restoration, enemies walking, etc). The state the game is in with ZERO input from the user is the default state you want, and any other state must be told "idle state is not playing" (and idle state should have "walking is not playing, attacking is not playing, jumping is not playing" etc.

I think comprehending the theory of game design is far more important than the code (with Construct 2 at least) but at the same time there are good practices no matter how one codes it. Just remember the computer isn't smart, you are.
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Mon Apr 07, 2014 6:43 am

Hi.

I cannot open the CAPX as im still on an old version.
Will download the newer version and have a look.

In the meantime.
The invisible box or "player helper" is the movement. The sprites on top of that are animations.
You go this route because your hitbox or collision detection on different frames change a lot on animated objects. So it just simplifies things and makes collision detection simpler.

TIP: do not use a square player helper. Cut the bottom corners. Prevents player getting stuck on small ridges.

For enemies. Use Turret behavior and platform behavior. No rotate for turret. Set events to simulate platform pressing direction of player.

Will make more sense later. Busy downloading newer version to have a look at your file
B
8
S
2
Posts: 163
Reputation: 1,115

Post » Mon Apr 07, 2014 10:25 am

@Ldk My animations are just sprites....the player box is the one set with the platform behaviour.
B
11
S
2
Posts: 61
Reputation: 704

Post » Mon Apr 07, 2014 10:41 am

Do you perhaps have another CAPX. im not too keen on using beta builds
B
8
S
2
Posts: 163
Reputation: 1,115

Post » Mon Apr 07, 2014 10:54 am

@Ldk Let me go download install the latest non beta build
B
11
S
2
Posts: 61
Reputation: 704

Post » Mon Apr 07, 2014 11:00 am

Oh i can no longer open the file as it's already saved in the latest r165 build....sorry :(
B
11
S
2
Posts: 61
Reputation: 704

Post » Mon Apr 07, 2014 1:38 pm

1) Create a new imagepoint on your sprite. Call it "punch"
Create a new event that pins the "helper" or punch collision box to that imagepoint of your sprite.
Detect collisions for punching the enemy from the helper you created and not from your player sprite.
If Punch Helper collides with enemy - destroy enemy

2) Use if key pressed. Not if key is down. If key K is pressed set animation to "player punching"
Create another event If animation "player punching" finished set animation to "Player idle"

3) Yes i had this issue as well. Create the helper object off the screen. Create an event that spawns a new helper and sets it position to the imagepoint as discussed earlier. On animation idle destroy helper

4) Give enemies platform behavior. Disable the default platform movement. Create a new helper. E_Jump or whatever you wanna call it.
Create an event if enemy collides with "E_Jump" helper then simulate platform pressing jump.

Basically you will need to place that helper at every possible place you want them to jump. Near edges of platforms.

I hope this helps. If not im planning on doing a tutorial soon on how i did all my platform movements and enemies.
B
8
S
2
Posts: 163
Reputation: 1,115

Post » Tue Apr 08, 2014 2:45 am

@Ldk thanks for these suggestions, let me go try them out and i will post an update here
B
11
S
2
Posts: 61
Reputation: 704

Post » Tue Apr 08, 2014 7:31 am

@Ldk i have tried your suggestions. They somehow work but not really as intended as they were supposed to. I wonder if Construct 2 is glitching the game or i did it wrongly. I have attach screenshots below to give a better understand of the issues.

1) I had already created an imagepoint and a collision box for the hit detection and i have also pinned the collision box onto the fist of my character. The reason why i have 2 imagepoints so that they will be able to display the collision box when i'm facing mirrored and non-mirrored way while punching. But i think i may have missed out something here and i ended up with this instead.

As you can see, the non-mirrored side's collision box is displayed correctly just nice over the fist
Image

but for the mirrored side, i get this instead
Image

Below here is my code
Image

So i need to have the collision box be displayed correctly on the mirrored side.

2)I can't seem to find the event where it says when "player punching" animation is finished, set animation to "player idle". What i did was instead this. But i still can hold down the punch button even thou it's already set to "On Pressed"

Image

3)I have already did that and the collision box is outside of the screen and i tried to add in the "destory" box after animation ends but i get the issue of my player punches once, the box comes up then disappears after going back to idle animation and then it doesn't appear back even i pressed punch again. It seemed to be destroyed forever.

this is the code
Image

4) I managed to solve this by adding in helpers and it works.

Hope others can learn from this also! :)
B
11
S
2
Posts: 61
Reputation: 704

Post » Wed Apr 09, 2014 3:53 am

bump for others to have a look :)
B
11
S
2
Posts: 61
Reputation: 704

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, Resslx and 42 guests