FlashyGoblin Posted January 2, 2017 Share Posted January 2, 2017 Looking for the best approach to create a simulated timeline of actions/events. For example, over a 2 minute timeline I would like to animate my camera around my scene on a curved path, and have numerous things happen at certain times in my timeline. I could create a timer/timeline object from scratch, but was wondering if there is a better BJS way of handling this. Imagine a camera navigating through a house, at 10 seconds in the door opens, at 15 seconds a light turns on, at 25 seconds a painting on the wall rotates and falls to the ground. Also looking for an approach to easily tweaks the timeline of events. Does this sound like something that should be handled within Unity or in code. Interested in everyone's thoughts. Thanks! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 2, 2017 Share Posted January 2, 2017 off the top of my head... var start = (new Date()).getTime(); action = function(name, time, callback){ this.name = name || "New-Event"; this.time = time; this.callback = callback; return this; }; var events = [new action("Step-1", start+(1000*6), function(){...}), new action("Step-2", start+(1000*10), function(){...}), ] onbeforeRegister => for(var i=0; i<events.length;i++){ var cE = events; var now = (new Date()).getTime(); if(cE.time < now){ var cE = events.splice(i,1); i--; cE.callback(); } } should get you in the right direction. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2017 Share Posted January 4, 2017 This may be not enough but why not just using setTimeout in this case? Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 10, 2017 Share Posted January 10, 2017 A rather belated answer but I have been spending sometime getting to grips with BJS animation object. Will add some documentation to the following PG in the week but shows how it is possible to produce a sequence of animations http://www.babylonjs-playground.com/#2L26P1 GameMonetize and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted January 10, 2017 Share Posted January 10, 2017 why not using animation events of @Temechon ? It is directly integrated in bjs Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 10, 2017 Share Posted January 10, 2017 @Luaacro I believe I am using the integrated animation events as in line 33. If there is a better way of putting together a sequence of animations then I would be very grateful to learn how. The PG is just one I made from what I have learned so far. Any adjustments very welcome. Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 12, 2017 Share Posted January 12, 2017 Still learning - in writing the documentation for the PG I gave in earlier post I came up with a simplified way of putting together animations which you can find written about here http://babylonjsguide.github.io/gamelets/Sequence though you might also want to read this first http://babylonjsguide.github.io/basics/Starter GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.