Notifications
Clear all

[Closed] A button that makes animation

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 .

6 Replies

Well you can do this with the main max interface using autokey!
But if you want it in code:


addNewKey $.pos.controller slidertime
1 Reply
(@wamo)
Joined: 11 months ago

Posts: 0

thanks dude for answer but i did right now and it again doesn’t move
try it plz it doesn’t move at all.

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

1 Reply
(@wamo)
Joined: 11 months ago

Posts: 0

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:

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?

1 Reply
(@wamo)
Joined: 11 months ago

Posts: 0

yep,now it works so i should store old values,thanks aLOt Dave

yes Exactlly!