Rolling
with Expressions (L6)
A quick tutorial by the Kevman. Intro
In this simple tutorial,
I'll explain how I worked out the solution to keeping wheels rolling in
perfect time with a car, even if you decide to speed up or slow down...
Well, to be exact, I'll show you how to roll one wheel - The other
3 or more will be simple duplicates of this one wheel! :)
Before we start lets get some basic information to help us work out how we're going to calculate the wheel rotating. We know the following things about wheels:
Usually I'll play with some numbers on paper to test my theories. Lets quickly make an example to test to prove this is correct: Lets say for example, our circumference of the wheel is 2m. The car moves 3m forward,
so that's 3m / 2m = 1.5 - So our wheel has to have rotated 1.5 times to
at 3m...
We know that a complete rotation is 360 degrees, so therefore we can work out that the rotation of a wheel at a given time will be: (Current distance of car / Circumference of wheel) * 360 degrees Thats the expression we need!
This exercise will be very quick and easy - Simply click on the Graph editor,
then select the wheel object and select the wheel.Rotation.B channel.
From the Modifiers,
Add modifier / LW_Expressions. Then, double-click
on the LW_Expressions modifier to bring up its settings.
Finally, I calculate the wheels rotation in the Expression line. -360 * B - I used a negative number because using a positive number rotated the wheel in reverse! Feel free to change -360 to 360 and see for yourself! To test that this is working, move the 'car' null back 1m and keyframe it at 0. Move the 'car' forward 1m and keyframe at 60. You need to create keyframes, because the expression asks for the position of the 'car' at a certain 'Time' (ie. frame). Just dragging the null back and forwards will have no effect on the preview window, so don't be fooled that it isn't working straight away... Then play and you should see the wheel rotating in perfect precision! That's it!Please note that this expression will only work if the car is moving in a straight line. Its not designed to compensate for turning, reversing, and dropping wheelies! Also, with some simple alteration of the way this calculation works, you can move the car based on the rotation of the wheel instead! Ideal for animating objects moving along a conveyor belt perhaps? Or you can drag race that hot rod by simply controlling the speed of the wheel rotation! But I'll leave that as an exercise for you to work out - hint - Similiar formula, just reorder it a little! ;) I hope that this has been
eductional for some of you out there!
Kevin 'kevman' Phillips
|
||||
This page hosted by Get your own Free Home Page