Legacy GM mp_potential_step error

B

Bullseye

Guest
alright so, I've been using GML for a little bit now and I've only been making little one or two button games that I only put a couple of hours into but I recently started a game I want to put more time into and I've encountered a problem. I'm using the mp_potential_step to move and I made it to when an object made upon click collides with a prompt a variable I called global.pmove = true. when it is true the player moves to the object and picks it up and then pmove = false so it stops moving as well as hspd = 0 to do the same thing but when the player collides I get the following error


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_player:

Unable to find any instance for object index '9' name 'obj_ammo'
at gml_Object_obj_player_StepNormalEvent_1 (line 34) - mp_potential_step(obj_ammo.x,obj_ammo.y, hspd, false)
############################################################################################

if anyone with more experience than I do id be extremely grateful, thank you
 
M

Mishtiff

Guest
I would guess that you are destroying the obj_ammo on collision, thus causing this step event to crash.

Try adding this around your mp step

Code:
if(instance_exists(obj_ammo)){
   mp_potential_step(obj_ammo.x,obj_ammo.y, hspd, false);
}
 
Top