You can write simple expressions for almost every attribute in Maya.

For example:

A subtle camera shake animation

perspShape.horizontalShake=sin(time*3.14/20)*0.05*noise(time*0.2)
perspShape.verticalShake=-1*sin(time*3.14/20)*0.05*noise(time*0.2)
perspShape.shakeOverscan=1 + sin(time*3.14/20)*0.005*noise(time*0.2)

perspShape = the name of the node
horizontalShake/verticalShake/shakeOverscan = the specific attribute
sin() = sine function
time = Maya’s built-in time variable (in seconds)
noise() = a continuous function

How to write an expression:

  • Click in the attribute field
  • Type = (an equal sign) and than the expression

or

  • Right click on the Attribute name and choose Create New Expression

Tips:

  1. If you want bigger characters in the Expression Editor: press Ctrl + Mouse Wheel
  2. A cool way to copy the object and attribute name:
    Select it and drag and drop with middle mouse button
  3. The noise() is a continuous function. If you want a discrete one try the rand() function.
  4. Here are the Useful Functions link from the Maya help documentation:
    http://help.autodesk.com/view/MAYAUL/2017/ENU//?guid=GUID-B00C3232-BF83-433B-9AED-E983E4FBD5CA

Here is the playblast with the expressions (above):

Advertisements