So, not really sure what to say about this... First, lets ensure you are using the function correctly... The idea behind the "override object" function is that in your sequence you use a placeholder object with no code in it, and then when you create the sequence you call this function and swap it for one that has the code and variables you need. If that is what you are doing then we'll need to have some more concrete information about what is happening... for example, full details of the object you are swapping in and how you are using it.
I currently have 2 objects, obj_placeholder, and obj_hitbox. At the moment, both objects are essentially dummy placeholder objects with just obj_hitbox having a create event of a owner id variable defaulting to 0.
If I were to do the following:
GML:
function hitboxCreate(seq,owner){
_seq = seq;
_seq.playbackMode=seqplay_oneshot;
_seqLayer="seqLayer"
sprite_index = spr_StickmanBasicPunch;
image_index=0
_myseq = layer_sequence_create(_seqLayer,x,y,_seq)
_struct = layer_sequence_get_instance(_myseq)
sequence_instance_override_object(_struct, obj_placeholder, obj_hitbox);
}
It works as expected, but the obj_hitbox still has that owner Id default value of 0.
Here is a reference for what the output for this looks like:
https://giphy.com/gifs/jIyam5FqxmOU9ij5IF
My current goal is to modify that value on the fly when the function is called in order to avoid making a million different hitboxes. I figured the best way to accomplish this was by creating an instance of obj_hitbox, modify the value, and pass that instance to the sequence_instance_override_object function. It ends up looking like this:
GML:
function hitboxCreate(seq,owner){
_seq = seq;
_seq.playbackMode=seqplay_oneshot;
_seqLayer="seqLayer"
var inst = instance_create_layer(x,y,_seqLayer, obj_hitbox);
inst.ownerId=100;
sprite_index = spr_StickmanBasicPunch;
image_index=0
_myseq = layer_sequence_create(_seqLayer,x,y,_seq)
_struct = layer_sequence_get_instance(_myseq)
sequence_instance_override_object(_struct, obj_placeholder, inst);
}
Upon running this version of the function, this happens:
https://giphy.com/gifs/HQPyBABYw6qq1avuYa
As you can see, the instance blinks in and out of existence for some reason, and the sequence has been reduced to a single frame. I am unsure of why this is happening, but as far as I can tell in the manual, I should be able to use instances of objects in the override. Am I misunderstanding how it's supposed to work?
Also through my testing, there seems to be a permanently existing hitbox object in the game (my guess the new instance of the hitbox which disappears), but how to get rid of it I am unsure.
To get around the sequence limitations, I used an approach where the in-sequence objects would be inert "spawner" objects that would create the actual instance using alarms (which would then be separate from the sequence and unbound to it), would that be an option? (It was extra appropriate for my case since I specifically wanted every enemy spawner to create a random enemy, but it would work just fine with an 1:1 relationship too)
I think that this would probably be a good option for me as well, but my only issue is figuring out a way to pass the values to the newly created hitbox beyond creating an instance that the hitbox would need to look for and modify.
Thanks for your replies guys! I hope I was able to explain my issues a bit better. I really appreciate the help!