GameMaker: Studio

GameMaker: Studio

View Stats:
Torsten Jan 16, 2017 @ 10:10am
Unable to find any instance for object index '0'
Hi gamemaker users!
So im making a top down shooter and this comes up every time the obj_enemy touches the player object this error message shows up:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_enemy:

Unable to find any instance for object index '0' name 'obj_player'
at gml_Object_obj_enemy_StepNormalEvent_1 (line 1) - move_towards_point(obj_player.x,obj_player.y,3)
############################################################################################
this is my code:move_towards_point(obj_player.x,obj_player.y,3)
Last edited by Torsten; Jan 16, 2017 @ 10:10am
< >
Showing 1-5 of 5 comments
Blind Jan 16, 2017 @ 10:16am 
It is likely you are destroying your player object on contact, and as a result your enemies can't find a player to move towards.
Thew Jan 16, 2017 @ 10:34am 
BBX is probably right. It's always good practice to check if an object exists before you attempt to access it's properties.

In your case, you might want to try something like:
if (instance_exists(obj_player)){ move_towards_point(obj_player.x, obj_player.y, 3); }
Torsten Jan 16, 2017 @ 10:59am 
I dont think thats the problem, I tried to use you code Thew but it still doesnt work
Blind Jan 16, 2017 @ 11:15am 
Originally posted by Samizzen:
I dont think thats the problem, I tried to use you code Thew but it still doesnt work

The reason being is we don't know your exact problem so we can only extrapolate based on likely causes.
Thew Jan 16, 2017 @ 12:09pm 
Right, we'll need to see some of your code or we can only guess.

The error message is stating that the obj_player object is not found and cites that specific line of code (move_towards_point).
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Jan 16, 2017 @ 10:10am
Posts: 5