Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- import pymel.core as pm
- #define radius of the bouncing ball
- ballRadius = 2
- #create the ball
- ball = pm.polySphere(radius = ballRadius)[0]
- #rename the ball
- pm.rename('pSphere1', 'Ball')
- #translate the ball transform up so the bottom of the geometry is at 0, 0, 0 at frame 0
- pm.setKeyframe(ball.tx)
- ball.translateY.set(ballRadius)
- def bouncingBall():
- #Set tangents to slow in/slow out the ball
- pm.keyTangent(ball.ty, t=[1], outAngle='70')
- pm.keyTangent(ball.ty, t=[24], inAngle='-70')
- pm.keyTangent(ball.ty, t=[12], itt='spline', ott='spline')
- #Squishes the ball for the first frame
- pm.currentTime(1)
- ball.scale.set(1,-.2,1)
- ball.translate.set(0,0,0)
- ball.translateY.setKey()
- ball.scale.setKey()
- #Pops the ball up
- pm.currentTime(3)
- ball.scale.set(1,0.820,1)
- ball.translate.set(0,6,0)
- ball.translateY.setKey()
- ball.scale.setKey()
- #Slows in before middle frame
- pm.currentTime(9)
- ball.scale.set(1,1,1)
- ball.translateY.set(19)
- ball.translateY.setKey()
- ball.scale.setKey()
- #Returns ball to its normal shape for frame 12
- pm.currentTime(12)
- ball.scale.set(1,1,1)
- ball.translateY.set(21)
- ball.translateY.setKey()
- ball.scale.setKey()
- #Slow out
- pm.currentTime(16)
- ball.translateY.set(17)
- ball.translateY.setKey()
- ball.scale.set(1,1.17,1)
- ball.scale.setKey()
- #Stretches ball before last frame
- pm.currentTime(20)
- ball.translateY.set(4)
- ball.translateY.setKey()
- ball.scale.set(1,1.7,1)
- ball.scale.setKey()
- #Repeats first frame
- pm.currentTime(24)
- ball.scale.set(1,.2,1)
- ball.translateY.set(0)
- ball.translate.setKey()
- ball.scale.setKey()
- bouncingBall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement