从其他实例对象访问自定义实例变量

Accessing custom instance variable from other instance object

我基本上有这个:

Obj1 创建事件:

health_total = 50;
health_current = health_total;
health_text = instance_create(x,y-10,obj_health); // Object to show health of an instance object

health_text.origin = self; // Assign an 'origin' variable so I can access it later?

obj_health 绘制事件:

show_debug_message(origin.x); // <-- This works just great!
show_debug_message(origin.health_current); // <-- This throws error :(

我假设该变量可能是本地变量,但是我该如何使它成为 public? GML 对我来说有点新,但我对编程并不陌生。这让我很受伤。

使用id,而不是self

health_text.origin = id;