- Home /
Camera Script sync with Animation and Sound
So, i am doing cutscene where Sound, Camera, and Animations need to be Synced. I managed to do it perfectly, i am happy with how it goes most of the time. But there are random instances where i play the game and cutscene is mess. I noticed that Animations and Sound are synced every time, but Camera only most of the time. What bothers me the most is that I play cutscene, camera is changing positions and rotations faster than it should or slower than it should, then i change basically nothing (f. e. i create new object somewhere in scene, like empty box or something, or even i do nothing), play cutscene again, and camera is synced correctly! How! How camera works? I have a script, it has variable that goes up by 1 every frame, i check Animation Sample Rate Number, time, etc, and i write to that script according to variable when to change angle and when to change position. So what is my problem? I guess variable in my camera script is sometimes getting bigger simutianously with Animation Sample Rate, and sometimes it skips some frames or something. Is there any way to use Animation Sample Rate as variable in script? Or any other solution to camera script syncing out of animation and sound? Animation and sound seem to play synced well even though they are different components on different objects in scene (of course played at the same time) I repeat, most of the time everything is perfectly synced, like 9/10 times, but in some cases camera does this weird stuff.
Answer by BlAcK_BlAcKiTo · Jul 09, 2018 at 07:46 PM
So I managed to solve this problem, problem was of course that Animation and sound were playing normally but camera was falling behind, as if scripts were going slower, and this happened only sometimes, which was the most annoying part of problem. I solved it. Yes i use Java.
var ObjectWithAudioSource : SoundTrack;
function Update() { Debug.Log(ObjectWithAudioSource.time);
if(ObjectWithAudioSource == 1){ //something } }
Now I beautifuly track Camera in Seconds, Animations in Seconds and Sound in Seconds. Great! So simple .time
Your answer