Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where's the Code View? #19

Open
tomaszzackiewicz opened this issue Jan 5, 2017 · 4 comments
Open

Where's the Code View? #19

tomaszzackiewicz opened this issue Jan 5, 2017 · 4 comments

Comments

@tomaszzackiewicz
Copy link

I would like to drive some things in the MateAnimator via code, but I cannot find the Code View that is in the PDF documentation file and I don't know how to start. Do I need a Unity Animator or Animation component attached to the game object? In general, it would be great to get a video tutorial, especially for API and coding. I mean the whole process form adding an object and animate it to manipulate the animation in code like Play, Pause, Stop, resume, etc.

Thank you.

@ddionisio
Copy link
Owner

Code view and json exporter are disabled for now, much of the infrastructure has changed and those two features would need a major overhaul. I haven't had a chance to look into it.

For the most part, the documentation still explains the core part of how the animation system works. A new documentation and video/project sample are also something I've been meaning to get out. Now that the plugin seem pretty solid at this point.

Once you have the animator dialog open, it should be straightforward from there. Access it from Window->Cutscene Editor. From there, clicking on Create AnimatorData will either add the component on a currently selected GameObject, or create a new GameObject.

The AnimatorData is basically what holds all of the animation info. So this can be part of the root game object, or it can be a child. This is also the Component you'll pretty much interact with in script for playing, pausing, etc.

@tomaszzackiewicz
Copy link
Author

Ok, I understand that. But how to control the anim from the code? I have an animated game object and it plays in the Timeline and in the Play mode. But how to control Play, Pause, Stop from the code? And more important for me - what is possible to do at runtime? Can I use the Timeline at runtime, changing for example anim (Keyframes, some properties, etc) during playing?

@ddionisio
Copy link
Owner

All of those are found in AnimatorData, simply grab that component, and you can check the public access in that script.

The animations are baked into DOTween's sequence, so a lot of the data from AMTakeData, AMTrack, etc. will not have much use at runtime. But you can still manipulate the tweens via the currentPlayingSequence.

With the AnimatorData, you can also add callbacks for when takes complete, or when triggers happen via a Trigger Track.

Example:

var anim = GetComponent<AnimatorData>();

//If you want to respond after a take has finished playing
anim.takeCompleteCallback += delegate(AnimatorData a, AMTakeData take) {
    if(take.name == "death") {
        //proceed to game over
    }
}

//If you want to respond to trigger track
//In this example, you'll want to reference a Transform/GameObject for positioning the spawned projectile
anim.takeTriggerCallback += delegate(AnimatorData a, AMTakeData take, AMKey key, AMTriggerData data) {
    if(data.valString == "fire") {
        //Spawn projectile
    }
}

anim.Play("takename");

//If you want to do stuff with the DOTween sequence, just don't destroy it
var curSequence = anim.currentPlayingSequence;

@tomaszzackiewicz
Copy link
Author

Thank you. I needed that. Now, I know what to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants