1

I am encountering this error with game maker and I do not know how to fix it. The error is


#

FATAL ERROR in action number 1 of Step Event0 for object obj_meatball:

DoAdd :2: undefined value at gml_Script_enemy_wander (line 4) - phy_position_x += sign(targetx - x)

############################################################################################

stack frame is gml_Script_enemy_wander (line 4) called from - gml_Object_obj_meatball_StepNormalEvent_1 (line 3) - script_execute(state);

My Code is stated below:

///enemy wander script_execute(checkplayer)

phy_position_x += sign(targetx - x) phy_position_y += sign(targety - y)

Any help will be much appreciated

Thankyou

Morgan
  • 71
  • 1
  • 2
  • 8

1 Answers1

1

Well, first of all, you can't have two "+=" in one instruction, I am pretty sure you meant to write :

phy_position_x += sign(targetx - x) phy_position_y + sign(targety - y)

Secondly, you forgot to add an operation between "sign(targetx - x)" and "phy_position_y"

And thirdly, you have to make sure that you initialized targetx before you start using it

can you give us more information about what you wanna do and which event you wrote the code in ?

  • GMS allows code like `phy_position_x += sign(targetx - x) phy_position_y + sign(targety - y)`, read it as `phy_position_x += sign(targetx - x); phy_position_y + sign(targety - y)`. I think the problem is uninitialized `targetx` and `targety`. – Dmi7ry Jan 23 '19 at 16:16