How do i sync sound with animtion

ive been trying to get into animation since i kinda gave up on scripting and ive been using moon animator which is really helpful!
ive been trying to sync the animation with sound so it has a nice effect and i was wondering how to do that?
i dont know if its scripting or any genre so i put it in game design support

ive been using google and youtube mainly but now as i post this im going to look through the forums.

3 Likes

ive seen these type of animation from moon animtor on youtube with sound is that from scripts or editing magic?

I am a scripter for scripts it can be implemented by loading the animation and directly playing sound after that.

2 Likes

but it cant be like synced, right?

I am certain loading animation doesn’t yield means the script doesn’t wait for the animation to finish.

And many fps games sync sound with animation like this way.

2 Likes

oh that kinda stinks but is there a way to accomplish what im trying?

Sync the sound with the TimePosition of the animation you are trying to play.

2 Likes

I didn’t get exactly why you said it stinks

And you were asking to sync sound with animation right?

1 Like

yes, and i replied with that stinks to “animation doesnt yeild” thinking with my problem

1 Like

thats a good idea but wouldnt it offsync with lag?

1 Like

Just check the TimePosition on the server, even if the client is lagging the players around it will still hear the sound in the way you want to. The thing is if you use wait() statements between playing the animation and playing the sounds the results might be a bit more off than if you were to use TimePosition.

1 Like

Yeilding means

Say you have this code

Animator:LoadAnimation(blahblah);
Print(hello)

If LoadAnimation yielded then the script would wait till the animation finishes and then print hello but it doesn’t means you can swipe the print(hello) with Sound:Play(). And it will fire directly after the animation the time difference is so little that its not that noticable.

1 Like

You could use AnimationEvent’s to sync up sounds with animations with this signal.

https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/GetMarkerReachedSignal

How to create an AnimationEvent:

  1. Go into the Animation editor.

  2. Right click anywhere on the timeline and click “Create Animation Event”
    image

  3. Call the Animation Event anything you want so we can reference it later in a script, then click save.
    image

Great! Now we have our Animation Event. You can drag this AnimationEvent anywhere you want in the Animation timeline to time whenever it’s going to happen. Now you can use GetMarkerReachedSignal to play the sound whenever it reaches the point we put it at in the Animation timeline.
image

Here’s a quick example:

Animation:GetMarkerReachedSignal("Animation Event name"):Connect(function()
	print("Marker reached.")
    --Play the sound
end)
14 Likes

how would i do this in moon animator now that i know?

As someone who has never used the Moon Animator that much I’m not entirely sure. You could maybe just export the animation then load it into the normal editor.