PDA

View Full Version : A button that makes animation


wamo
05-26-2008, 01:20 PM
Hi everybody,
i got a bad problem here below and donno how to solve it:

ie i have a Box(),also i have a Button that should make keys for animation of this box,
now what i want is: when i move mybox to wherever in the scene and press button ,it automaticly Calculate the $box.trasnsform and make the animation between last transform and new transform,
as you now i can handle it manuelly like this:
with animate on
(
at time slidertime $box01.pos = [30,30,30]
)
so this code is complatly manuely to handle and if i change the box's transform to for example [50,50,50] and press button again it makes the key again for [30,30,30].
hope you guys got what i mean,

i was wondering if you guys could help me out .

davestewart
05-26-2008, 01:25 PM
Well you can do this with the main max interface using autokey!
But if you want it in code:


addNewKey $.pos.controller slidertime

wamo
05-26-2008, 01:30 PM
Well you can do this with the main max interface using autokey!
But if you want it in code:


addNewKey $.pos.controller slidertime
thanks dude for answer but i did right now and it again doesn't move
try it plz it doesn't move at all.

davestewart
05-26-2008, 01:40 PM
Yup - you need 2 keyframes for an object to move, so you'd need to run the code twice, moving the box inbetween.

Are you familiar with basic animation principles?

Dave

wamo
05-26-2008, 01:48 PM
Yup - you need 2 keyframes for an object to move, so you'd need to run the code twice, moving the box inbetween.

Are you familiar with basic animation principles?

Dave
yes yes Dave i know Basic animation priniciple,and know it needs 2 keys to move between,
even if i run this script in to difrent timeslider frame and twice it makes the keys but when i move timeslider it dosen't show any animation between.donno why!!! :argh:

davestewart
05-26-2008, 02:01 PM
Ah, Ok, sorry!

Of course, if you mov ethe box without Auto Key on, ALL your keyframes are going to move (check it out in the track view).

Perhaps you want to store the position and slidertime as variables when you first press the button, then the second time you press it, you set the first keyframe and update it's value, AND set the second keyframe and update its value at the same time:

t = slidertime
p = $.pos

-- move slider and box

addNewKey $.pos.controller slidertime -- add the new key
with animate on at time t $.pos = p -- animate the old position

Are you trying to replicate Set Key functionality?

wamo
05-26-2008, 02:19 PM
yep,now it works so i should store old values,thanks aLOt Dave :)

Are you trying to replicate Set Key functionality?
yes Exactlly!

CGTalk Moderation
05-26-2008, 02:19 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.