1

Hey I'm doing some basic programming in GML and I was trying to use a variable in one object to effect another. Pretty simple I just used:

[Obj_PlayerManager.Create] Dmg = 1

[AsteroidParent.Collision(Obj_Laser)] Hp -= Obj_PlayerManager.Dmg

But when run it states that the variable Dmg hasn't been declared. I tried to figure out what it was cause it's pretty clearly declared and best I could find was Dmg stayed greyed out no matter what. Anyone have any idea why?

2 Answers2

3

I found it after taking a break and coming back. Must have been a bug in the software, but essentially I couldn't save the manager object. I closed Gamemaker and reopened it later and, while I had to redo the snippet of code, it worked perfectly.

TL;DR

It's the tried and tested "have you turned it off and on again?"

bbnumber2
  • 643
  • 4
  • 18
0

Has Obj_PlayerManager been placed in the room too? If it's not placed in the room as well, then it'll be threated as it does not exists.

If you're making use of multiple rooms, then manager/provider objects should have the 'Persistent' value checked on, so it'll remain to exist even when swapping rooms.

Another idea is to put the Dmg on the laser object, and call it in the collision event through Hp -= other.Dmg

Steven
  • 1,996
  • 3
  • 22
  • 33