Object oriented event system

Hello, I’m not exactly sure how to ask this so my title might be off/misleading. I really don’t know what the system is called that I am looking for so if anyone has any ideas please let me know.

Basically what i want is to be able to in editor assign a series of methods to an object that would fire one after another (once the previous one is completed). For instance say i want a sprite to first enlarge then spin and finally to explode. I would like the ability to have separate scripts for each action and set those actions in order in the editor (ideally along with some definable variables - like duration etc). Anyway I’m not sure if it is possible/how to approach the system. Any thoughts?

This would be a great question for the Scripting forum. If you post your question there, I’m sure you’ll get lots of responses.

(p.s. - Also look into a cutscene editor such as uSequencer, Cinema Director, or Animator Timeline Editor.)

You could create an array of scripts, expose them to the editor and if you were sure that each one of those scripts would have the same method you could just call it. The best thing to do would probably make it all inherit from an interface, the interface could be something like IEffect

You could always just create a simple class that contains all of the possible actions - attached to the sprite as a component.

A public string to hold the sequence (in some format you predetermine) - e.g. sp6,en2,ex. And a parser to execute it.

I’m cheap and nasty though. You might want a fancier solution than this :slight_smile:

Example:

public string spriteSequence;

private void Start()
{
    // CALL THE PARSER OR JUST PARSE IT RIGHT HERE.   
}

private void Enlarge(float amount)
{}

private void Spin(float amount)
{}

private void Explode()
{}

Thanks for all your replies. Some really good ideas which has got me thinking. I’m not super familiar with animation clips. I wonder if i can create a public list (array) of anim clips that I can just drag and drop onto the object.

If your functions had a predefined value of sorts, you might not even need any event at all.
I mean, when you call 3 functions one after an other in the code, unless you are calling them a special way, they will execute in the sequence you give.

Which makes me a bit unsure if I actually understood the question to begin with.