Scene starting at a random time (and continue)


#1

Hello everybody,
I’m trying to create a slideshow, along one timeline, starting randomly at the beginning of the scene.
So far I tried this little javascript based on advices I found on this forum. Unfortunately this doesn’t work.
I’m a total beginner in Javascript and would be really thankful for any help.

Cheers, Quentin

var timeInSecondsForJumping = ["0","3", "6", "9", "12", "15", "18", "21", "24", "27", "30"];
var randomTimeInSecondsIndex = Math.floor(Math.random() * timeInSecondsForJumping.length);
var randomTimeInSeconds = timeInSecondsForJumping[randomTimeInSecondsIndex];

hypeDocument.goToTimeInTimelineNamed(randomTimeInSeconds, Timeline principale);

(Hans-Gerd Claßen) #2

desttime for an timeline will expect integer or float as an argument wether you provided a string.
have to say that this is not clearly stated out in the documentation
var timeInSecondsForJumping = [0,3,6,…];
should work, don’t forget to continue the timeline after going to time …


#3

Hi Hans-Gerd,
thank you for answering my question ! I made the correction but unfortunately this doesn’t seem to work.
For making things easier, I provide an exemple.

Cheers, Quentin

GotoTime_Random.zip (17.7 KB)


(Mark Hunte) #4

It is probably better you have the animation on a different timeline to the Main one.

In your javascript you had incorrect syntax when calling

hypeDocument.goToTimeInTimelineNamed()

Also I added the continue timeline into the Javascript and changed the Timeline Action to Run the Javascript.

That setup may not be exact what you want (Timeline Action ) but this should show you what you need to do…

GotoTime_Random.hype.zip (13.1 KB)


#5

Hello Mark,
thank you very much, that’s it !
I could complete my project, and I appreciate you took time for me.

Best regards,
Quentin