Notifications
Clear all

[Closed] Play Animation at random times

Hi guys,

for my current project it would facilitate my animation process a lot if I could solve my problem with MaxScript.

I have several objects of which each has to move to one point and back at a set speed and at random times. Like frog that sits on one side of the street and jumps to the other side and back if he’s getting poked.

I thought the best way would be to check for a “poke”, determine when the object is at the target position, so it wouldn’t accept any more “pokes” until it’s back at its original position. But then, how do I determine the current position of the object? this.pos does not work since it is a script controller. I’d be glad if someone can shed some light on this.

Thanks in advance!

Regards,
eclaw

2 Replies
 eek

Just script it, over time:
– point and frog must be in different locations

(
local target = $frog
local point = $point01
local endPos = [0,0,0]
local interval = 10
local sTime = 0
local eTime = (sTime + interval)

local startPos = $point01.pos

for f = animationRange.start to animationRange.end do
(
slidertime = f

if (f => eTime) then
(
startPos = point.pos
local r = random 0.0 1.0
sTime += interval
eTime = (sTime + interval)
target.pos = ((1 - r) * target.pos + ((1-0.5) * target.pos + [0,0,0] * 0.5) * r)
)
else
(
point.pos = (((f-sTime)/(eTime-sTime))* startPos.pos  + ((f-sTime)/(eTime-sTime))*target.pos)
)



)


)

something like this roughly…

Wow! I kinda got it to work on my own (took a few hours, it’s my first script), but yours looks much more elegant. Thanks man!