How do you make someone meelee attack in game maker 7?

1 answer

Answer

1163991

2026-05-04 08:55

+ Follow

Depends on what type of attack you are trying to achieve, you did not provide enough information. but ill try to help anyways.

for a platform game, if by attack you mean shoot, then simply make an object that you want to use as a bullet, and then for the keypress event for shooting, simply add a code which creates an object, gets its ID, then sets the speed in the desired direction. example:

B=instance_create(x,y,obj_bullet); //create a bullet and save its ID in the variable 'B'

B.direction=direction; //the direction we want the bullet to go.

B.speed=12; //make the bullet move with the speed of 12

now simply add collision events within the bullet object, and lets say, for example, it hits an enemy, you would either destroy the enemy, or subtract lives from it.

for this example, lets say your enemy has a variable called "hp" which is how many lives it has. Now whenever it is hit by a bullet, it will lose 5 lives, and if its lives go below zero, or equal zero, it is destroyed.

First, we want to give the enemy lives, so in the create event we will add this piece of code:

hp=20; // the amount of lives the enemy has

then in the collision event we simply subtract 5 hitpoints, and destroy the bullet so we dont lose lives again.

hp-=5; //subtract 5 hp

/*destroy the bullet. in collision events, the object that collides ID is saved into the variable "other" so we can use that for things like destroying it, reading data, changing its direction/variables, and pretty much anything else you can think of. */

with(other)

{instance_destroy();}

Hope that helps. you didn't provide enough information, so I cant give you an exact solution.

~grumpymonkey from the GMC

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.