Im very new to unity and game development in general. In fact this is my very first posting to any game development site or forum!!
My main interest is not so much gaming as such (boo hiss i hear you cry lol), but using unity to deliver a VR Music Video experience.
My issue is that at ‘around abouts’ a certain time into a song (game time) i want an object or objects to to something etc. the objects are ‘reacting’ to a certain part of the song.
i can make the objects move ok at any particular point in the song via scripting ok, HOWEVER…
when i want to view the results of my coding - ie the events actually happening, i have to press play in unity and wait n watch until the events take place to check that their movement is having the correct desired effect.
In practice i often have to tinker with each objects timings to fine tune their effect.
As each time i have to play and wait some mins and seconds to view the result of my tinkering… it becomes ever more annoying and time consuming.
I would be most grateful if anyone could suggest a way (Scripting??) that upon pressing unity’s play button, the game (music video) starts just before my objects are about to move… so i can easily adjust and re-test etc.
Many thanks in advance
The problem is that you’re approaching Unity as a linear system, in which the animation of events is strictly time-limited, repeatable, and deterministic. In most games, this simply isn’t true. The events occurring at 02:40 into a game of Super Mario Bros are different on every playthrough for every player, because they’ve been dependent of user input, and you can’t simply jump to that part of the game without evaluating all of the preceding events that led up to that point (i.e. playing the game).
If you don’t require any interactivity, you could set up all your gamebject animations to be triggered from an Animator controller. Then, using Animator.StartPlayback you can explicitly set time.value to evaluate an arbitrary frame in the animation. Likewise, you could use AudioSource.time to specify the matching time from which the audiosource should be played. However, note that depending on how you are compressing the audio, time might not be exact - it will only be a multiple of the closest audio packet start point.
Many thanks for your quick reply. I appreciate that games generally arent linear systems.
however i am wanting to use the unity environment as the arena for a 3D virtual reality (occulus rift) music video.
Whilst the music is running some events will happen when a user does something, but some other things i wish to happen at specific times in the song that is playing.
i can already make them happen at ‘more or less’ specific times by triggering them at specific game times …however ideally as several things are happening around the same moment I would really like to be able to jump immediately to a specific point of the song - which will in effect be at a specific point in game time (i.e time in the vr music video) … this will let me see the timed events play out at the correct point in the music so i can fine tune them etc.
i was just wondering was there a way to jump straight to a specific game time… so that i can quickly and repeatedly observe the music and any ‘syncronized’ / timed events and how they perform at that time.