Yes, you can do that. However, there’s a few things that you have to take into account. Either you put everything inside the Sequence GO, and then when you’re spawning the prefab everything is ready to go, or you need to make sure that before you play (or init) the sequence, you have either the GameObjects you used or you assign new ones to those timelines.
Flux stores the reference to the GO that owns the timeline, but since the GO may not be in the scene already - and since there’s no other way to get that information - , Flux looks for the GOs by path name. So lets say that you have a character called Enemy8 in your hierarchy, Flux will store “/Enemy8” as the path of the owner of the timeline.
So you have 2 ways to do it when the GOs are outside the sequence:
a) You spawn those GO with the same name, and then Flux will get them
b) You spawn GO to replace those, and you have to assign them in their Timelines
(a) is the easiest, however some times it isn’t practical (e.g. the player can be using FemalePlayer or MalePlayer GOs, but you want them to play the same thing). BTW this is also a limitation when you have to assign like this multiple GOs with the same name, Flux will just grab the first with that name.
(b) is the solution for when you need to replace things, but it implies that you need to search que sequence timelines and set a new Owner (e.g. When you created the sequences you used MalePlayer, so if the user is using FemalePlayer, you search for all the timelines whose owner was MalePlayer and then replace him with FemalePlayer).
Did you understand the options? I know it is a bit complicated, some times when you work with prefabs these things get a little muddy.
Ok this is where things start to get murky. Flux was created for creating cinematic kind of content, so basically cut scenes, scripted events, intros, etc. When you start mixing gameplay with Flux, you start going into rogue territory, because Flux is meant to create something that plays the same way.
So I’d say that the best gameplay scenarios for Flux are things like quick time events, which play out like movies, but then there’s an event that makes it jump to another sequence or another part of that same sequence. Other good examples that I see is assume that there’s a “scripted city collapsing” behind our character, and then it either plays out without killing him, or if it catches the player it kills him, or a turn based game where you have these scripted attacks.
It’s not that you can’t do gameplay with Flux, is that it will start to get “ugly” and in some instances hacky. So I caution ppl on how they use it because in some situations it may not be the best option.
For this I have 1 doubt, if they can play the sequence at the same time:
- Enemies can play at the same time - spawn N enemies, then spawn N sequences. For each enemy, assign him the timelines of his sequence.
- Enemies cannot play at the same time - spawn N enemies, then spawn 1 sequence. Before each enemy can play it, you need to call Stop(true) (true is to force it to init before playing again), then assign the timelines to that enemy, and only after that play the sequence.
If I understand this correctly, you’d want to have an event that sets the owner of the timeline? That will be worse, because you’ll now have to find specific events and set variables on them. Also, it wouldn’t work because the owners have to be assigned to the timelines before the timeline starts playing. This is to be more optimised, because we have an init phase in which you can cache stuff so that you can be ready for playing without any overhead (i.e. frames dropped).
That being said, I’m adding 2 functions right now, a FSequence.ReplaceOwner( Transform oldOwner, Transform newOwner ) and a FSequence.ReplaceOwner( string timelineName, Transform newOwner ), where timelineName is the name of the GO. I may also add one that uses the Transform path, I’ll think about it (only helpful when you have more than 1 GO with the same name and inside other GOs).
These will be on Flux 2.0. After spawning a sequence, you’d just have to do something like:
sequence.ReplaceOwner( “MalePlayer”, femalePlayerGO ).
Hope I answered your questions, if not let me know ;-]
Regards,
Nuno Afonso
http://www.fluxeditor.com