We succesfully exported a maya motion path using maya2egg and we were able to parent a node to the motion path and use a moPathInterval to move it along. We’re having trouble getting the node to follow the actual curve of the path; it seems to want to stop at each point on the path. Also, the speed at which the node travels seems to depend on the distance the points on the motion path are from eachother. In other words, the movement DOES follow the path, but the speed is constantly changing at each point on the path, making the movement very jerky. Any ideas?
here’s my code:
# set up a dummy node to follow the motion path
self.moPathDummy = render.attachNewNode('moPathDummy')
# parent another dummy node to moPathDummy so we can change the penguin's pos and hpr
self.penguinDummy = self.moPathDummy.attachNewNode('penguinDummy')
self.movePenguin = MopathInterval(self.motionPath, self.moPathDummy)
self.moveCamera = MopathInterval(self.motionPath, self.cameraDummy)
self.move = Parallel( self.movePenguin, self.moveCamera )
self.move.start(startT=0, endT=5000, playRate=5)
We used endT= 5000 because we didn’t know how long the level was. I upped the playrate to 5 because some parts of the level were going extremely slow (the parts where the points on the moPath are close together, like a smooth turn), but now some parts are going extremely fast (the “straightaway” parts where the points are far apart). Now the “turning” parts are pretty close to what we want, but the “straight” parts are far too fast.
Do we have to put all the points in the motion path the same distance from eachother to get truly smooth movement, or is there some other way? Forgive me, I just can’t understand how these panda motion paths work.
Thanks in advance,
The Mopath follows the parametric specification of the curve itself–that is, the object moves smoothly in t, as t progresses from 0 to the end of the curve.
If the object stops and starts at every point, it’s because the curve itself stops and starts at every point. It might not look that way, but that’s the way the curve is built on the inside.
I don’t know much about the curve-editing tools in Maya, but I bet there are some utilities there to reconstruct a new curve that has the same shape as the curve you have drawn, but is smoothly distributed parametrically.
If nothing else works, you can hand-edit the egg file and change the “knots” values so that they evenly increment, and so that the first and last numbers are repeated three times–for instance, 0 0 0 1 2 3 4 5 6 7 8 9 9 9. You just have to make sure the total number of knot values remains the same.
I checked the egg file, and the knots tag is just as you told us to do it…we have 500 points on the curve, and the knots tag says:
The movement is still very jerky, so I think you were right, the curve must be built in small straight segments and the dummy node is following the segments…
Looking at it in maya though, it looks like a curve to me
Not sure how to fix this…
Try reducing the number of points. You really only need one point for each major left-right change in direction. Having too many points tends to make any curve act jerky.
There are tools within almost any NURBS modeling package to rebuild or recompute a curve or surface using fewer points. I’m sure Maya has them too.
Thanks for your help =)
Another quick question for you:
I know I can set the playrate on a motion path when I play it, but can I adjust the playrate on the fly without the object on the path “snapping” to the new rate?
We’re having a penguin slide down a tube, and he’s going to battle a polar bear at the end of the level. The player only controls the penguin’s roll…his forward motion is constant, unless he hits a rock, in which case I want to slow him down (without using moPathInterval.pause() ) and then resume the path with a blendType=‘ease-in’. How can I adjust play rate on the fly like this?
I also have this problem when the penguin is fighting the bear. If the player hits a rock, I want the player to slow down but the bear to keep going. Then I will have the bear slowly come back to the player, so it looks like the player is “catching up” to the bear. This seems like it would involve slowing the playrate of the bear, unless I should just use a posInterval to bring the bear back after a couple seconds. If the bear hits a rock, I want the same thing: the bear slows down, the penguin does not, but the bear catches up every time.
Sounds like you need to take more direct control of sliding down the path than a MopathInterval can really give you. You can still create a Mopath, but just call mopath.goTo() each frame to move the penguin and the bear to their appropriate points.
You’ll be responsible for determining the appropriate values of t for both the penguin and the bear each frame–you’ll have to work out the logic for this that is most appropriate for your application. But in general, t = 0 will be at the start of the Mopath, and t = mopath.getMaxT() will be at the end of it.