How do I get the time position of a sound instance?
So I’m making a battlegrounds game, and I have this animation for the ult awakening. I also have some sound that goes with it which is about 41 seconds long. It has speaking in it and also has some clothing movement SFX which will go with the animation. The only thing I’m worried about it how I can sync the animation with the sound.
MAIN ISSUE:
The first issue I came across was trying to get the correct time positions of when the clothing sfxs or speaking played. These time positions can be turned into when certain parts of the animation will proceed. This is my primary problem since the one following won’t be detrimental in my case. To avoid confusion, this sound is being synced to one animation. The animation I have, has nothing in it. It’s empty because I don’t have the time positions yet.
The second issue is just scripting it but I should have no problem doing that once I get the first issue solved.
Ask any questions and if I didn’t explain well enough I will try to elaborate.
This seems to work … I left the testing parts in also.
local sound = workspace:WaitForChild("Sound")
sound:Play()
task.wait(3)
print("x")
local timePosition = sound.TimePosition
print("Time Position:", timePosition)
local position = string.format("%.3f", timePosition)
print(position)
this can work, but do you think there would be any better way to do this? I’m assuming the battleground devs had some way of doing it more efficiently. Syncing a sound with an animation has many different paths of success, I’m just looking for the best one.
I really don’t know … that is an odd read as if you’re looking at it in the studio it will not look like it’s updating. Click off and back on and then it changes. You may have to go watch a few animation tutorials. I’ve never messed with that myself … good luck!
yeah the time position is always at 0, if it actually updated accordingly I would probably be able to work with it. Also what do you mean by clicking it on and off? Click what on and off.
It’s updating like it should … it’s just don’t look like it’s updating. If you click on something else then click back on the sound it will show it is updating. The script will always be able to tell you where it is. The number comes back with many places after the decimal point, so I used string.format(“%.3f”, to get it down to 3 after the decimal. So, you can’t test for say 1:05 as it will read a very long number. So you would have to use > to check if it is past that amount.
In this case 1:05 would be 1.08333 so you would test for if A > 1.08 then … or maybe 1.0799.