Blog about Maya, Realflow, Vue, Mentalray, Cryengine 3, ZBrush, Cryengine, Blender, Gimp and XNA
Sunday, February 3, 2013
Rotating object using mel script
Adding Mel Script to your object is easy way to animate it. Go through the Maya documentation and you can learn it easily. Now lets see how to rotate your object using Mel Script.
Go to Attribute Editor(ctrl+a) right click on the rotate X value. Click Create New Expression. Then type this script and click create(pCylinder1 is the name of my model).
pCylinder1.rotateX=time*100;
Now play it. You can see your object is rotating alone X axis. Change 100 to higher value and it will increase rotating speed of your model. Change X to Y or Z to change rotating axis.
Adding throttle Attribute to your object to control speed.
Select your object and Click Modify->Add Attribute. Enter following values.
Long name=throttle
Data Type=float
Minimum=1
Maximum=10
Default=0
Click OK. Now you can see throttle attribute in your Attribute Editor. Go to Expression Editor and Change the script.
pCylinder1.rotateX=time*pCylinder1.throttle*100;
Change the value of throttle while playing your animation. See the result. You can use this method for Helicopter Rotor or Boat Propeller or something.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment