melee
Started by domthebomb, Jul 01 2012 07:00 PM
4 replies to this topic
#1
Posted 01 July 2012 - 07:00 PM
i am making a platformer and i know how to shoot and all that stuff but how in the world do you doa melee attack that when the enemy touches the sword it will take damage im so lost please help
#2
Posted 01 July 2012 - 07:07 PM
What code do you currently have? You'll probably want a small invincibility frame for the enemy, so set a variable to 5 and decrease it (or set an alarm). While the variable is larger than 0, make it so the enemy can't take damage. You probably also want to knock back the enemy, so you probably want to set hspeed and vspeed to something upon sword contact with enemy.
#3
Posted 01 July 2012 - 07:09 PM
Create an object at the players sword that if enemies touch they lose health? There's really many ways to go about this! You should probably give more information or a screenshot.
#4
Posted 01 July 2012 - 07:18 PM
is it a punch? or is it something that can be interchangeable like a sword/spear/bat?
if its the first one best thing to do is to make a image on your player sprite of a fist being threwn from the player.
then have your event for when the player takes damage exlude thie image.
e.x
now for a sword or something its best to have a seperate sprite and object for the game.
then have 2 images 1 with sword still and 2nd with the sword at a wacking angle.
then same as before witha simple change.
e.x
if its the first one best thing to do is to make a image on your player sprite of a fist being threwn from the player.
then have your event for when the player takes damage exlude thie image.
e.x
Spoiler
now for a sword or something its best to have a seperate sprite and object for the game.
then have 2 images 1 with sword still and 2nd with the sword at a wacking angle.
then same as before witha simple change.
e.x
Spoiler
#5
Posted 01 July 2012 - 09:22 PM
If it's a punch, check the sprite_index and image_index of the player to verify that he's punching the enemy and not simply running into the enemy. DO NOT USE A LARGER BOUNDING BOX. The bounding box should always be the same as when the player is just standing idle. You will need to then check for a collision with the enemy a distance from the bounding box edges based on how long the punch extends.
It's all pretty simple, really. Although you may want to consider using collision_line() to check for a collision only where the fist is at.
But for swords and stuff, use a separate object like everyone else already said.
It's all pretty simple, really. Although you may want to consider using collision_line() to check for a collision only where the fist is at.
But for swords and stuff, use a separate object like everyone else already said.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











