Set driven keys

Hi to all,

If I make a set driven key in Maya, this script can be used inside Unity?

Thank you in advance

We don't import driven keys, but you can easily write a small javascript that matches the same behaviour.

Hi Joachim,

That's are bad news for an artist ho w knows art tools!
Where can I learn javascript to achieve that? Tutorials on the net, js for dummies?

Thank you in advance

If someone explains in detail what set driven keys are in detail maybe someone will write the script and put it on the wiki.

Hi Aarku,

Set driven keys are a way to help to make animations and their rigging (Set up) easier. For the animators.

For programers it`s like make one element do somnthing when an atribute (In this case frame or key freme) has been reached.

Plese check these two links:
http://www.ryerdesign.com/tutorials/sdk/index.html

http://www.graphics.cornell.edu/academic/DigitalArtsGraphics/animation-spring06/FAQ.html

At this moment. I want to make that my tires (Tyres, depend on your country) turn fast when the car goes fast and turn slow when it goes slow, and off course, stops if the car do it.

Thank you in advance

Assuming you have a speed value in your moving the car script, just use that value to rotate the tyres by. If it's too fast/slow, just times it by a chosen value.

I see that this post is quite old. I don't know if you now have support for driven keys in Unity or not. They seem to play but that may just be a bug. In any case there are a great many things that driven keys can do that would be very useful if they were supported.

I have worked with other engines that support driven eyes and allows for some very useful things to be done. Using a driven key for a single rotation is generally not done because it would obviously be easier to script. They are for things like tank treads, pulleys, or any kind of complex machine that has multiple rotations, translations, scale, or other keyable attributes, driven by a single variable.

Many of these things simply cannot be scripted. They must be animated, but an animation loop will not work unless Unity can dynamically play the animation forward or backward based on an input or variable.

On my current project we are deeply in need of this because there are many highly complex machines and mechanisms that are interacted with directly by the player along with rigid bodies and other dynamic objects.

I hope this clears up some of the reasons that driven keys are different from keyframe animation and why it is very important in interactive settings.
Please ask me more if you need to know.

Any other tech artists on this forum? We need to get these Unity guys interested in this stuff!!! 8)

Why not just use your driven keys to drive bones which in turn deform your mesh? For mechanical objects just do a rigid bind (1 bone per vertex) and you can build as complex of a control system as you want in Maya. If you stick with an unbroken (single chain) hierarchy for each main section and use Unity's hierarchical system for assembly it should work really well.

As you say, it IS common these days for engines to support both morph/mesh/blend animations and skeletal but the trade off in performance vs. file size is huge. Many people are using Unity to dev for iPhone and web-player 3D games. Skeletal animation usually takes more processing but allows for extremely small files sizes which for artists (like me) mean more variation in animation.

I'll also add that the restrictions of Unity's basic skeletal system can be a benefit to the design of the game as it forces one to be more creative with what exists as opposed to the consistent complaint and request for new features (which artists, myself included, are famous for). :)

You are thinking more in terms of a control rig, which we are using for all of our characters. Our characters all use expresions, driven keys, and direct connections to drive the joints for our animators. We can do any animaiton that can be done in maya and transfer to an FK only rig for use in Unity.

This is however not at all what I am talking about in terms of Unity supporting driven keys in the engine. We want Unity to support Driven Keys in the engine so that we can do more complex interactions between the player and complex machines and characters in game.

Here is an example. Say you have a character like Wall E who is a robot that moves around on tank treads. Those tank treads need to be animated dynamically when you move the character. The faster he moves, the faster the animation that plays on the treads moves. This happens regardless of what other animations are playing on his upper body. This is one spot where a Driven Key is the best way to do this. To script this would be impossible given all of the translations and rotations of all of the individual joints associated with the tank tread.

To be clear. I am not talking about ways to control a rig or to animate, I am talking about driven keys being played in Unity and being able to be dynamically driven by player input or otherwise.

Joachim and socksy allready told you how to do it. Set driven keys are just simple functions relating two or more variables, easy to develop in Unity with a simple script. For a tank tread you would need to build a 360 rotation loop for them inside your animation app., and then inside Unity you would use a script to play this loop with a velocity depending on the actual movement of the GO.

Ah I see there is a variable for animation speed and it is able to play it backwards as well. So yes, an animation could be made and Unity can play it forward and backward at any speed.

AnimationState.speed
var speed : float
Description
The playback speed of the animation. 1 is normal playback speed.
A negative playback speed will play the animation backwards.
// Walk backwards
animation["Walk"].speed = -1.0;
// Walk at double speed

In essence simulating a driven key. The only problem here is that the character would have to be split up in order to play different animations on the upper body and lower body.

For instance the Wall E example. The tank treads would have to be one file with an animation on them that is driven by the speed of the character, and then the upper body would have to be another file, parented under the tank treads, which plays arm, spine, head anims etc..

This is not ideal and driven keys would be better because if you want to run more driven key anims on the upper body. For instance a rotating radar antenna, always spinning on his head. You have to split the radar into a separate file and play an animation on that, how would you parent it to his head and have it move with his upper body animation?

This can be done through animation blending of course (which I don't know if Unity supports), but a driven key would still be better in almost any case.

Anyway, we will get by without driven keys for now but it would be great to have them supported down the line.

You don't need to split the character at all, you can set all those separate behaviours using animation layers and additive mode. Animation blending is of course suported, and many more options too. I see you are really new to Unity, so I would suggest you to take a look at the animation API before asking for more allready present features ;)

Ah!! Now I see that Unity has support for all kinds of animation blending and the ability to control individual joints dynamically. :) Yes I'm new to unity and didn't even see that whole section about how Unity supports additive and overlay animation. This is Great!!

Thank you GusM!

Yes this pretty much eliminates the need to import driven keys, however it would still be nicer since it is easier to tweak their values in Maya rather than in the editor.

No files would need to be split up and it looks like Unity will be able to do anything that we need. :lol:

N.p., enjoy Unity ;)

As first a Maya user, and second a Unity user, I "get" what he is trying to do. Set Driven Keys are behaviors that are based on a slider. They can be simple, or pretty complex. An example of a complex SDK is the robot arm emerging from a robot, with all of its pistons and animations controlled by a single slider:


I actually got this to work with animation, and an animation controller per SDK. The workflow is this:

1) create an animation that represents your SDK. In my case, it was a LED light going from close to black to pure red.

2) create an animation controller

3) add your animation clip to the controller

4) create a float parameter in your animation controller

5) add an Animator component to the object that you want to control, and add the animation controller to that component. If you want to reuse the SDK in various objects, you still will need one animation controller per object (otherwise they will activate in unison)

6) I added the following script to the object. This script was reusable in all objects that I wanted to light up the LEDs (the up, down, left, and right feedbacks for a joystick).

public class acendeLED: MonoBehaviour
{

    Animator animator;  // empty container for the object´s animator

    [Range(0, 1)]  // pretty cool way to create a slider with min/max
    public float acendeLED1;   // this will be linked to the animator´s parameter, and exposed on the object so that you can link to it from another script, or move the slider by hand to test the SDK


    void Start()
    {
        animator = GetComponent<Animator>();  // just gets the actual Animator component assigned to the object, and assigns it to the "animator" variable
    }

    void Update()
    {
        animator.SetFloat("acende", acendeLED1);   // this is what links the float/slider on the object to the Animator parameter. Once linked, the float will control the animation, and in effect you have your SDK!
    }

}