Jump to content


Photo

melee


  • Please log in to reply
4 replies to this topic

#1 domthebomb

domthebomb

    GMC Member

  • GMC Member
  • 63 posts
  • Version:GM8

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 :medieval:
  • 0

#2 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1092 posts
  • Version:GM7

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.
  • 0

#3 Robert3DG+

Robert3DG+

    VR Games

  • GMC Member
  • 1841 posts
  • Version:GM:Studio

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.
  • 0

#4 robinsblade

robinsblade

    GMC Member

  • GMC Member
  • 661 posts
  • Version:GM8

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
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

  • 0

#5 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 4686 posts
  • Version:GM8

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.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users