• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Kill Enemies code

tox_von

Member
i tried putting this

GML:
if (place_meeting(1,1,Object2)) instance_destroy();

for if an arrow hits the enemy what is wrong with it?


Does anyone have the code for if an arrow hits the enemy it gets removed?
 
  • Wow
Reactions: Mut

tox_von

Member
im just looking for the code i need im messing around with the basics of the program before i start more complex stuff.
 
...The code you need is literally in the manual entry that I linked you. If you're a beginner, reading the manual entry for any functions you don't understand is step number one if something isn't working how you expect.
 

tox_von

Member
GML:
if (place_meeting(x, y, Object2)) instance_destroy();
i tried this if thats what you mean but it didnt destroy the instance.
 

tox_von

Member
no im just begging for the code i need. i dont really understand how to use this for what im trying to do.
 

woods

Member
if (place_meeting(x, y, Object2)) instance_destroy();

i tried this if thats what you mean but it didnt destroy the instance.
what DID it do?
did you try adding a with other in that mix?





no im just begging for the code i need. i dont really understand how to use this for what im trying to do.

there is ALOT of helpful people here..
but to straight up sit here with a hand out... bro, zero effort is gonna get you pretty much nowhere ;o)
 

Joe Ellis

Member
"Objects" are assets. "Instances" are kind of like live versions of the base "object", clones.. They run all the code in the object's events, and can be created and destroyed.

The code "if (place_meeting(x, y, Object2)) instance_destroy();" will destroy itself it collides with Object2.
I don't know what Object2 is, is it the arrow or the enemy?
I think probably the easiest way to do this would be, in the arrow object, make a collision event with the enemy object, and simply do:
GML:
instance_destroy(other.id, true)
This will destroy any enemy instance that it collides with.

Or you could do it the other way round and put a collision event in the enemy object with the arrow object, then you'd just put:
GML:
instance_destroy()
That'd destroy itself(the enemy) and execute it's destroy event if it has one.
 
Last edited:
Top