View Full Version : donkey follow carrot setup problem
06-23-2003, 12:21 PM
I am trying to setup a shark swinning in a random changing direction. I have managed to hammer out an expression which rotates a locator in a new direction every few seconds. My problem is that I cant get the shark to swim in that direction.
I currently have the locator attached to the shark and then have another locator off that one in front of the shark. The idea is to get the shark to follow the locator like a donkey would a carrot but the parenting/constraints create a loop that makes my shark look like a breakdancer. Perhaps I need another approach.
Any ideas most welcome
06-23-2003, 05:22 PM
Why dont you just apply the same expression to the translate and rotates of your actual shark. If you dont want to do that, because you want to be able to animate the shark on top of the moving animation, then just group the shark node and apply the expression to the new group, now you can still go and animate the node under this group to make the shark do alternative things. Hope this helps! If not, let me know.
06-23-2003, 05:42 PM
Thanks for the reply!
This won't work because the shark still travels in the same direcition, namely z, as the expression only applies to the rotation. So what you get is a shark that turns one way but still keeps going in the same direction. Any other ideas
06-23-2003, 06:09 PM
I'm not really with you on this one. Maybe you can be a little more descriptive about what exactly you want the shark to do. Also maybe give an example of your expression, so I can see exactly what the problem is.
By the way, I just noticed Cape Town. What company in Kaap Stad do you work for??
06-24-2003, 06:35 AM
I dunno if there's a better way of doing it. If you could somehow switch the evaluation of translate and rotate that could work... but this method should be fine for ya.
Use an aim constraint then frameCache nodes on the translation (so it moves behind the locator).
here's an example:
Aim Constrain nurbsCone1 to locator1
createNode frameCache -n fcX;
createNode frameCache -n fcY;
createNode frameCache -n fcZ;
connectAttr locator1.tx fcX.stream;
connectAttr locator1.ty fcY.stream;
connectAttr locator1.tz fcZ.stream;
connectAttr fcX.past nurbsCone1.tx;
connectAttr fcY.past nurbsCone1.ty;
connectAttr fcZ.past nurbsCone1.tz;
That should be it. Drop some variables in there and MEL the aim constraint if you are gunna do it more than a few times. You could prolly do a school of them a similar way.
06-24-2003, 10:50 AM
What if when you put the expressions on the shark, you tell it to move along it's local Z axis rather than the world axis. Then the local Z axis should rotate and move the shark in the right direction.
06-24-2003, 03:37 PM
That is exactly what I need to happen! Just how you do it is a mystery. How do you rotate an object and get it to translate in local space?
Must be a command or something.
And Loked I am a freelancer. Get in touch. firstname.lastname@example.org
I'll be in Jhb next week
06-25-2003, 12:27 AM
Ok, I got it to work just now.
Here are the expressions I used on a poly cube:
if (frame == 0)
move -a -xyz 0;
pCube1.rotateX = 0;
pCube1.rotateY = 0;
pCube1.rotateZ = 0;
if (frame > 0)
move -os -r -z -0.2;
pCube1.rotateY = sin(frame/4)*20;
A basic overview is that on frame 0, the cube's translation and rotation values are set to zero. Then when the animation is played, the cube moves -0.2 units in the Z direction, relative to where it was on the previous frame, and it moves in object space. The sin function on the rotate Y is just to make it wiggle and to prove that it will move properly.
So that's it! But for some reason you need to hit rewind (back to frame 0) twice for the rotation values to be set to 0.....
Good luck! :thumbsup:
01-15-2006, 12:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.