How to punch/kick in adventure game? [SOLVED]

PortableAnswers

New member
Hello, how can I make my player punch or kick in my adventure game? I have the animations and I tried using the Melee_H and Melee_V game objects but no success. Thanks!
 

jorotroid

Member
Can you elaborate on what you have tried doing so far? Punching and kicking could mean different things for different games, so it's hard to give advice when I don't know what sort of punching and kicking your are going for.
 

PortableAnswers

New member
jorotroid said:
Can you elaborate on what you have tried doing so far? Punching and kicking could mean different things for different games, so it's hard to give advice when I don't know what sort of punching and kicking your are going for.

Ok, I mean punching and kicking in the sense of a Beat 'Em Up like say Kung Fu Heroes. That game is in the perspective of a traditional top-down adventure game like Zelda but you are more-so kicking and punching like Double Dragon than using a sword like Link.

Thus far, I have been messing around with Melee_H under Game Objects. I have set up my frames, object details (chose player weapon and set speed), and set the bounding box. Then I added the melee script that came with NESmaker to execute when I press B.
 

jorotroid

Member
Hm, is anything happening at all when you press B? Can you show a screenshot of the script and also as screenshot of the input editor? Maybe to be thorough also a screenshot of Melee_H's Object Details?
 

jorotroid

Member
Oh, I just remember one aspect to the adventure module that you might have skipped. Go into Project>Info and make sure that Weapons 1 and 2 are unlocked. The melee and projectile scripts won't work unless you have those checked.
 

PortableAnswers

New member
jorotroid said:
Oh, I just remember one aspect to the adventure module that you might have skipped. Go into Project>Info and make sure that Weapons 1 and 2 are unlocked. The melee and projectile scripts won't work unless you have those checked.

Yes, someone reminded me of that last night and it worked! ... kind of.
My melee is a sprite of my character doing a kick. When I press B, I see the whole sprite next to my player. It does not replace the player so there are two players on screen. I put the melee sprite right on top of my character with the Game Objects tool for projectiles and melee placement but that did not work.

Thank you for your help thus far! :)
 

jorotroid

Member
You're welcome! I hope we can get this all sorted out for you.

Hm, I think I am getting a better picture of what you are going for. It sounds like your sprite for the kick is a completely redrawn version of you player sprite with body and all. If what you are going for is for the leg your kick to be outside of the normal confines of the size of the player sprite, then you'll want the kick melee sprite to be of just the leg. And with the player set up an animation of the player kicking with the leg cut off.

For a bit of a visual reference check out the gif in this tutorial I made. In it, I am not replacing the entire player object when punching, I am changing the player's state to the attacking animation state and placing an arm object in front of the player.
http://nesmakers.com/viewtopic.php?f=3&t=1018
 

PortableAnswers

New member
jorotroid said:
You're welcome! I hope we can get this all sorted out for you.

Hm, I think I am getting a better picture of what you are going for. It sounds like your sprite for the kick is a completely redrawn version of you player sprite with body and all. If what you are going for is for the leg your kick to be outside of the normal confines of the size of the player sprite, then you'll want the kick melee sprite to be of just the leg. And with the player set up an animation of the player kicking with the leg cut off.

For a bit of a visual reference check out the gif in this tutorial I made. In it, I am not replacing the entire player object when punching, I am changing the player's state to the attacking animation state and placing an arm object in front of the player.
http://nesmakers.com/viewtopic.php?f=3&t=1018

I think that this is indeed what I need! I will give this a try soon and report back. Thanks!
 

PortableAnswers

New member
jorotroid said:
You're welcome! I hope we can get this all sorted out for you.

Hm, I think I am getting a better picture of what you are going for. It sounds like your sprite for the kick is a completely redrawn version of you player sprite with body and all. If what you are going for is for the leg your kick to be outside of the normal confines of the size of the player sprite, then you'll want the kick melee sprite to be of just the leg. And with the player set up an animation of the player kicking with the leg cut off.

For a bit of a visual reference check out the gif in this tutorial I made. In it, I am not replacing the entire player object when punching, I am changing the player's state to the attacking animation state and placing an arm object in front of the player.
http://nesmakers.com/viewtopic.php?f=3&t=1018

Thanks for the help so far. I followed your tutorial but no luck yet. Yes, my melee sprite is a completely different sprite and not even close to what the walking and idle sprites are.
 

jorotroid

Member
Hm. I'm not sure what the best advice for you would be. So you seem to be going in a bit of a different direction than how melee object offset was intended to be used. Also you have a sort of unusual character. It looks like your intention is to have the melee object appear over the player object, but the issue you are having is that it's appearing off to the side. If I remember right, this is probably because the script that determines where the melee object appears was sort of built to handle smaller melee objects, so the math is off when you try to use such a big object for the melee attack. You can compensate for this by editing some values in the melee script. That said, if you go the way you're going, you'll probably end up with being able to see the regular player object underneath the melee object whenever you attack. You're also setting yourself up for some additional challenges by having a character that is wider when going left and right than when it goes up and down. I'm not saying that what you are going for is impossible, but you are heading down a road of having to customize more code, and I thought I should at least point that out. Have you gone through the video tutorial for the adventure module yet? I highly recommend getting to know how the tool is intended to be used before going off script in the way you seem to be going.

Aside from all that, for the attack state I would maybe look into making the front of the donkey use the player object and the kicking legs be the melee object. That would be more in line with what the melee object offset was built for. Or maybe the whole player object can handle all the different animations and you could overlay an invisible melee object to handle the attack collision.

I'm not sure how comfortable you are with code, so I'm a bit reluctant to go into too much detail. But if you want to dip your toes in, I can tell you that where to fix the offset. Go in the b_create_melee script and around line 45 you should see the number #$08 and little further down #$10. These numbers represent the dimensions of the expected melee object in hexidecimal. In other words it's expecting an object that is 8x16 pixels (the size of the sword in the adventure tutorial). You'll have to change this numbers to reflect the size of the melee object you use.


That's a nice looking donkey, by the way.
 

PortableAnswers

New member
jorotroid said:
Hm. I'm not sure what the best advice for you would be. So you seem to be going in a bit of a different direction than how melee object offset was intended to be used. Also you have a sort of unusual character. It looks like your intention is to have the melee object appear over the player object, but the issue you are having is that it's appearing off to the side. If I remember right, this is probably because the script that determines where the melee object appears was sort of built to handle smaller melee objects, so the math is off when you try to use such a big object for the melee attack. You can compensate for this by editing some values in the melee script. That said, if you go the way you're going, you'll probably end up with being able to see the regular player object underneath the melee object whenever you attack. You're also setting yourself up for some additional challenges by having a character that is wider when going left and right than when it goes up and down. I'm not saying that what you are going for is impossible, but you are heading down a road of having to customize more code, and I thought I should at least point that out. Have you gone through the video tutorial for the adventure module yet? I highly recommend getting to know how the tool is intended to be used before going off script in the way you seem to be going.

Aside from all that, for the attack state I would maybe look into making the front of the donkey use the player object and the kicking legs be the melee object. That would be more in line with what the melee object offset was built for. Or maybe the whole player object can handle all the different animations and you could overlay an invisible melee object to handle the attack collision.

I'm not sure how comfortable you are with code, so I'm a bit reluctant to go into too much detail. But if you want to dip your toes in, I can tell you that where to fix the offset. Go in the b_create_melee script and around line 45 you should see the number #$08 and little further down #$10. These numbers represent the dimensions of the expected melee object in hexidecimal. In other words it's expecting an object that is 8x16 pixels (the size of the sword in the adventure tutorial). You'll have to change this numbers to reflect the size of the melee object you use.

That's a nice looking donkey, by the way.

Thank you for all the feedback! I have some Unity experience but this is my first game. I have watched almost every video on the New 8-Bit Heroes YouTube channel. I would have never made it as far as I've gotten without them. 6502 is still something that I am learning...slowly. Just taking it day by day. I will poke around in that script and report back if I make any progress. Perhaps version 4.1 will have something that will suit this situation. If not, I still have a lot of work to do on other aspects of the game so if the solution doesn't come immediately then I certainly have enough to keep me busy in the time being.

I'm glad you like Swamp Donkey :mrgreen:
 

dale_coop

Moderator
Staff member
The melee object will never "replace" your player graphics. It's just an add-on.
But when you use the weapon, you player change its animation (action step 2, if I remember well... cf the adventure tutorial).
So your PLAYER should have the attacking graphics animation, used in its action step2. And your Melee object should just be invisible (with a bounding box), at the same spot than your player foot/leg maybe...
 

PortableAnswers

New member
dale_coop said:
The melee object will never "replace" your player graphics. It's just an add-on.
But when you use the weapon, you player change its animation (action step 2, if I remember well... cf the adventure tutorial).
So your PLAYER should have the attacking graphics animation, used in its action step2. And your Melee object should just be invisible (with a bounding box), at the same spot than your player foot/leg maybe...

This worked! Thanks!
It happens in the blink of an eye. How can it be configured so the attack animation is shown for longer? I adjusted the animation speed for the Player's Attack and the also Melee animation speed but no luck yet.
 

dale_coop

Moderator
Staff member
Yeah, I think, you could slow down your animation (the "animation speed" for the "action step 2", for example "08") and don't forget to set the "End of animation" to "GoTofirst" (the "End of action" remains to "Null").
And take a look at that topic: http://nesmakers.com/viewtopic.php?f=3&t=1018
 

PortableAnswers

New member
dale_coop said:
Yeah, I think, you could slow down your animation (the "animation speed" for the "action step 2", for example "08") and don't forget to set the "End of animation" to "GoTofirst" (the "End of action" remains to "Null").
And take a look at that topic: http://nesmakers.com/viewtopic.php?f=3&t=1018

Got it to work! I had to give the attack animation at least 2 frames.
 
Top Bottom