• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Ai problems in pong game.

J

Jakob Åsmul

Guest
Hi!
I followed a tutorial on YouTube that showed me to make an AI player in a pong game, and then, this message showed up:


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

Variable object_ai.object_ball(100002, -2147483648) not set before reading it.
at gml_Object_object_ai_StepNormalEvent_1 (line 1) - action_move_to( 0, (object_ball.y - y) / 6 );
########################################################################################

Does anyone know how to fix it?
 
R

rui.rosario

Guest
It's a little hard to guess without further context, but from the look of it there seems to be a mismatch from where you assign the object_ball variable and where you use it.

It seems you are trying to use the object_ball variable in the Step Event, are you assigning it before (eg. Create Event)?

Also, given that it seems you name your objects object_*, are you sure you have a ball instance created before trying to run that code that uses it?
 
J

Jakob Åsmul

Guest
It's a little hard to guess without further context, but from the look of it there seems to be a mismatch from where you assign the object_ball variable and where you use it.

It seems you are trying to use the object_ball variable in the Step Event, are you assigning it before (eg. Create Event)?

Also, given that it seems you name your objects object_*, are you sure you have a ball instance created before trying to run that code that uses it?
Yes, I am sure that i have a ball instance created before. Do you say that i should use a create event?
 
J

Jakob Åsmul

Guest
Yes, I am sure that i have a ball instance created before. Do you say that i should use a create event?
I wrote all the stuffs the tutorial told me to, but my game crashed. And he told me to use a step event.
 
R

rui.rosario

Guest
No, you should continue using the Step Event. My pointwas that if the object_ball didn't exist for some reason then the code would fail because the instance didn't exist (or the name was typed incorrectly).

Does the game crash as soon as the game begins or only after the first ball is destroyed or at another specific time?
 
J

Jakob Åsmul

Guest
I solved it! I called it object_pong, not object_ball. The tutorial did that.
 
Top