This document is about: QUANTUM 3
SWITCH TO

このページは編集中です。更新が保留になっている可能性があります。

Events

Overview

Quantum Animator provides support for Instant events and Time-Window events.

Creating a New Instant Event

Events assets can be created using Create->Quantum->Assets...

EventAsset creation

Instant Events will trigger only one time the Execute() function once the Animator plays the clip that contains such event baked. A good pattern is to inherit from the base AnimatorInstantEventAsset and override the base class methods with different procedures, like custom Frame.Siganls.

C#

public unsafe class AnimatorInstantEventAsset : AnimatorEventAsset, IAnimatorEventAsset
  {
    public new AnimatorEvent OnBake(AnimationClip unityAnimationClip, AnimationEvent unityAnimationEvent)
    {
      var quantumAnimatorEvent = new AnimatorInstantEvent();
      quantumAnimatorEvent.AssetRef = Guid;
      quantumAnimatorEvent.Time = FP.FromFloat_UNSAFE(unityAnimationEvent.time);
      return quantumAnimatorEvent;
    }

    public override void Execute(Frame f, AnimatorComponent* animator)
    {
      //Debug.Log("Execute Instant event.");
    }
  }

Event Setup

Follow these steps to define the event on an animation clip:

  1. Add the AnimationEventData component to the same GameObject the contains Animator component, in your QuantumEntityPrototype:
EventAsset creation
  1. On the Animation window select the clip and add a new Unity AnimationEvent:
EventAsset creation
  1. Select the created event and specify the Function and Object as the image below:
EventAsset creation

Creating a New Time-Window Event

The procedure is very similar to the instant event creation, the difference here is that you will need to create a second event of the same type in the Unity Clip to define the final of the event execution.

EventAsset creation

In case you want to create new events that have a similar behavior with OnEnter(), Execute() and OnExit() methods, by inherit the AnimatorTimeWindowEventAsset class:

C#

[Serializable]
  public unsafe class AnimatorTimeWindowEventAsset : AnimatorEventAsset, IAnimatorEventAsset
  {
    public new AnimatorEvent OnBake(AnimationClip unityAnimationClip,
      AnimationEvent unityAnimationEvent)
    {
      //...
    }
    
    public void OnEnter(Frame f, AnimatorComponent* animator)
    {
      //Debug.Log("OnEnter Time-window event.");
    }

    public override void Execute(Frame f, AnimatorComponent* animator)
    {
      //Debug.Log("Execute Time-window event.");
    }
    
    public void OnExit(Frame f, AnimatorComponent* animator)
    {
      //Debug.Log("OnExit Time-window event.");
    }
  }
Back to top