Notifications
Clear all

[Closed] Object direction of animation

I’m attempting to rotate the object in the direction of it’s animation.
Seems like it is close.


(
	delete objects
	tp = teapot size:10 pos:[0,0,0]

	posArr = for i = 1 to 20 collect ([(random -200 200),(random -200 200),(random -200 200)])
	idx = 1
	for i in 20 to animationrange.end by 20 do 
	(
		animate on (
			at time i (
				tp.pos = posArr[idx] 
				tp.dir = posArr[idx+1] 
			)
		)
		idx += 1
	)
)

1 Reply

A few things:

  1. Direction is defined along the Z-axis. Which on a teapot is pointing up, so you will need to compensate for that.
  2. You need to set the direction ahead of the position, something like:
at time (i-20) do (
tp.dir = posArr[idx]
)

before you set the position in the existing code. Otherwise you are looking ahead at frame 20, but not for frame one and the last frame as idx+1 will eventually error out.

-Eric