C
Cooltrain
Guest
Hey all,
So I've been working on a character change system and have hit (what seems like) a simple issue that I just can't seem to get around. I'll go ahead and give the code first before explaining my issue.
Obj_player_controller : create (this is the object in the room)
The character that is then created would run two scripts, one in the create and one in the step
Obj_Char1 or Obj_Char2, ect create and step
These scripts would then get which character was created ( and is active) in the create event, this is the same for both the create and step
scr_playerCharInt
This is the main area of focus though
My problem is that in the controller create event, the instance of the character is created before currentCharObj has been set. The scripts for the created character create event then check currentCharObj to see which the current character is but it still hasn't been set because both create events are triggering at the same time. Ideally I would just switch the lines so that instance create is last but I need it to be able to call it in the next line for the currentCharObj ? I think I need a way of the scripts not running until the create event in the controller has finished maybe ? For example if i manually set currentCharObj = 1 or 2 before the instance create then it solves the issue (1 or 2 is the object Index for the two current characters ).
Thanks for any help or advice.
So I've been working on a character change system and have hit (what seems like) a simple issue that I just can't seem to get around. I'll go ahead and give the code first before explaining my issue.
Obj_player_controller : create (this is the object in the room)
Code:
startChar=asset_get_index("obj_Char1");
currentChar=instance_create(x,y,startChar);
currentCharObj=asset_get_index(object_get_name(currentChar.object_index))
Obj_Char1 or Obj_Char2, ect create and step
Code:
//create
scr_playerCharInt();
//step
scr_playerCharMovment();
scr_playerCharInt
Code:
/*Char1*/
if (obj_player_controller.currentCharObj=obj_Char1){
//Char1 init code
/*Char2*/
}else if (obj_player_controller.currentCharObj=obj_Char2){
//Char2 init code
}
Code:
startChar=asset_get_index("obj_Char1");
currentChar=instance_create(x,y,startChar);
currentCharObj=asset_get_index(object_get_name(currentChar.object_index))
Thanks for any help or advice.