Problem with animationEvents

Hi!

I’m having a problem with events, when I load a new scene on runtime/play it stays in the clip and when the event fires it is fired as many times as the scene has been loaded and the problem is. I have no way of knowing if the clip contains the event. (Or atleast I was unable to find anything related to this kind of problem)

Any help is appriciated :slight_smile:

    public override void Start()
    {
        base.Start();

        AnimationEvent newEvent = new AnimationEvent();
        newEvent.functionName = "AddJumpForce";
        newEvent.time = JumpForcePoint;
        newEvent.messageOptions = SendMessageOptions.DontRequireReceiver;

        base.Clip.AddEvent(newEvent);
    }

One way of fixing this was to create a container for clip, but I do not like this way…

        _clipContainer = (AnimationClip)Instantiate(base.Clip);
        _clipContainer.name = "jumpEvented";
        if (base.animation.GetClip(_clipContainer.name) == null)
        {
            AnimationEvent newEvent = new AnimationEvent();
            newEvent.functionName = "AddJumpForce";
            newEvent.time = JumpForcePoint;
            newEvent.messageOptions = SendMessageOptions.DontRequireReceiver;

            _clipContainer.AddEvent(newEvent);
            base.animation.AddClip(_clipContainer, _clipContainer.name);
            base.animation.RemoveClip(Clip.name);
        }

Please help me! :smile:

Anyone? :face_with_spiral_eyes: