From BlenderWiki

Jump to: navigation, search

Action Constraint

Mode: Object and Pose modes

Panel: Constraints (Object context and sub-context, F7, or Editing context, F9, when in Pose mode)

Description

The Action constraint is a quite powerful one, but also a bit tricky to understand. Basically, it allows you to map an action on the owner, using one transform property of the target to control where (or rather, when) in the action the owner lays.

Yes, I know, this is not very clear. First of all, you should know what is an action in Blender, else follow the link… And for those who know them, the underlying idea of the Action constraint is very similar to the one behind the Ipo drivers, except that the former uses a whole action (i.e. a bunch a Ipo curves of the same type), when the later control a single Ipo curve of their “owner”…

Note that even if the constraint accepts the Mesh action type, only the Object, Pose and Constraint types are really working, as constraints can only affect objects or bones transform properties, and not meshes’ shapes…

As an example, let’s assume you have defined an Object action (it can be assigned to any object, or even no object at all), and have mapped it on your owner through an Action constraint, so that moving the target in the [0.0, 2.0] range along its X axis, maps the action content on the owner, in the [0, 100] frame range. This will mean that when the target’s X property is 0.0, the owner will be as if in frame 0 of the linked action; with the target’s X property at 1.0, the owner will be as if in frame 50 of the linked action, etc.

Options

The Action constraint panel.
Target
This constraint uses one target, and is not functional (red state) when it has none.
AC
You must type in this text field the name of the action you want to use.
Exclamation mark.png
Even though it might not be in red state (UI refresh problems…), this constraint is obviously not functional when this field does not contain a valid action.
Key On
(by default shows "LocX")
This drop-down list controls which transform property (location, rotation or scale along/around one of its axes) from the target to use as “action driver”.
Start, End
The starting and ending frames of the action to be mapped.
Note that:
  • These values must be strictly positive.
  • By default, both values are set to 1, which disable the mapping (i.e. the owner just get the properties defined at frame 1 of the linked action…).
Min, Max
The lower and upper bounds of the driving transform property value.
By default, both values are set to 0.0
Exclamation mark.png
Unfortunately, here again we find the constraints limitations:
  • When using a rotation property as “driver”, these values are “mapped back” to the [-180.0°, 180.0°[ range.
  • When using a scale property as “driver”, these values are limited to null or positive values.
CSpace
This constraint allows you to chose in which space evaluate its target’s transform properties.

Notes

  • When the linked action affects some location properties, the owner’s existing location is added to the result of evaluating this constraint (exactly as when the Offset button of the Copy Location constraint is enabled…).
  • When the linked action affects some scale properties, the owner’s existing scale is multiplied with the result of evaluating this constraint.
  • When the linked action affects some rotation properties, the owner’s existing rotation is overridden by the result of evaluating this constraint.
  • Unlike usual, you do can have a Start value higher than the End one, or a Min one higher than a Max one: this will revert the mapping of the action (i.e. it will be “played” reversed…), unless you have both sets reverted, obviously!
  • When using a Constraint action, it is the constraint channel’s names that are used to determine to which constraints of the owner apply the action. E.g. if you have a constraint channel named “trackto_empt1”, its keyed Influence and/or Head/Tail values (the only ones you can key) will be mapped to the ones of the owner’s constraint named “trackto_empt1”.
  • Similarly, when using a Pose action (which is obviously only meaningful and working when constraining a bone!), it is the bone’s name that is used to determine which bone channel’s names from the action to use (e.g. if the constrained bone is named “arm”, it will use and only use the action’s bone channel named “arm”…). Unfortunately, using a Pose action on a whole armature object (to affect all the keyed bones in the action at once) won’t work…
  • Note also that you can use the pose library feature to create/edit a Pose action datablock… just remember that in this situation, there’s one pose per frame!


Examples

Object Action

We are going to control the size of our empty called "Owner" with the rotation around the Z-axis of the empty called "Target_1".

Create an Object action

First, let's create an Object action datablock.

  1. Select an object (which one is unimportant), and insert two scale keys. In the 3dview:
    • at frame 1, do S1, I  »  Scale
    • at frame 11, do S2, I  »  Scale
  2. In an Ipo window, Object curves, enable the "action" button to create an Object action.
    The Scale Ipo curves. Note the “action” button outlined in yellow.

  3. In an Action window, rename this action “ActScale”, and, after checking that the Fake user button is enabled (it is by default), click on the “X” button to remove this action from the object used to create it.
    The ActScale action.

Now we have an Object action datablock available called "ActScale".

Setup the Constraint

The Action constraint panel of our example.

Let's setup the constraint as below:

  1. Add an Action constraint to the empty Owner, using the empty Target_1 as target.
  2. In the AC text field, type in the name of our action (ActScale).
  3. Select Rot Z as input control property, setting Start to 1, End to 11, Min to 0.0 and Max to -90.

This way, rotating Target_1 from 0.0° to -90.0° we double the Owner scale.

You might have noted that this can be done much more easily with e.g. a Transformation constraint. This is true, but here you can make your action much more complex, making the scale to vary differently, adding location or rotation keys, etc.

Result

Object action example.
Target’s Z rotation to 0.0°.
Target’s Z rotation between 0.0 and -90.0°.
Target’s Z rotation to 90.0°.


Constraint action

Now, let’s see another, more advanced and complex example, based this time on a Constraint action.

We are going to control the Influence value of a Track To constraint through the X axis location of a same target, so that:

  • when Target_1’s X position is below 0.0, the owner does not track it at all (i.e. Influence value of its Track To is null).
  • when Target_1’s X position is between 0.0 and 5.0, the Track To Influence progressively grows up.
  • when Target_1’s X position is higher than 5.0, the owner fully tracks it.

Add a Track To constraint

Add a Track To constraint to Owner, with Target_1 as target:

  1. select the target and then the owner
  2. press CtrlAltC  »  Action).

Create a Constraint action

  1. Add a constraint to an object (constraint type and which object are unimportant!).
  2. Name it “trackto_trgt1”.
  3. Key its Influence value from 0.0 at frame 1, to 1.0 at frame 101.
  4. In an Ipo window, Constraint curves, enable the “action” button to create a Constraint action.
    The Constraint Ipo curves… Note the “action” button outlined in yellow.

  5. In an Action window, rename this action “ActConst”, and, after checking that the Fake user button is enabled (it is by default), click on the “X” button to remove this action from the object used to create it.
    The ActConst action.

Now we have a Constraint action datablock available, called “ActConst”.

Add an Action constraint

The Track To and Action constraints panels of our example.
  1. Add an Action constraint to Owner, using again Target_1 as target.
  2. In the AC text field, type in the name of our action (ActConst).
  3. Select Loc X as input control property, and set Start/End to 1/101, and Min/Max to 0.0/5.0.

On the right you can see the resulting Stack.

Result

Now, you can grab Target_1, you’ll see that when in negative X coordinates, Owner does not track it at all, while when its X coordinate is higher than 5.0, Owner fully tracks it…


Constraint action example.
Target’s X coordinate lower than 0.0: no tracking.
Target’s X coordinate between 0.0 and 5.0: partial tracking.
Target’s X coordinate between 0.0 and 5.0: partial tracking.
Target’s X coordinate higher than 5.0: full tracking.


Note that you can change the constraint which influence is controlled by the Action one, just by attributing to the chosen one the trackto_trgt1 name…