[sorted out]updating variables

RODO

Member
hello guys, i have a doubt about the create event and ways to update variables with new values.

well, I'm trying to create a system that passes information between instances and, I modified and updated its variables, however, when I was creating the system (I tried it in many ways, even with a step event) I realized that no matter what I did, the variable always came with original value (code below for better explanation):
GML:
//create event
//fighter life
hp_lutador = 64;

var player_lutador = instance_create_layer(x,y,"player",obj_player);
player_lutador.hp_max = hp_lutador;

explaining how the code works: I create an object that when it is created in the room, it creates the player's obj and then sends the variable information, and one of them is from hp. I would like to know why the value is always reset even if I ask or pass the modification information? I appreciate any help

NOTE: hp is zero in the player's create (actually obj_entidadee_player, which I created and only people that he is the son of obj_player)
 

TailBit

Member
You are setting hp_max, not hp.

The player create event happens the moment you do instance create
 
Last edited:

RODO

Member
You are setting max_hp, not hp.

The player create event happens the moment you do instance create
hum got it, tested it a little now and it worked. I really thought I could change one variable and it would change the value of another, but apparently the way I did it doesn't happen
 
Top