Sequencing anim vs sound
Blitz3D Forums/Blitz3D Programming/Sequencing anim vs sound
| ||
What is the best way to correspond an exact frame of animation to a sound? Here is the code I am working with, and I want the "PlaySound animates_clank1" to play about 1 second after the animation starts. It would be ideal to tell blitz exactly when to play it by knowing exactly which frame the animation is on. Can anyone help with this? Thanks in advance.
Global animates = LoadAnimMesh ("animates.b3d")
LoadAnimSeq (animates, "animates.b3d")
ScaleEntity animates, 5,5,5
PositionEntity animates,0,0,0
;load animates sounds
Global animates_clank1 = LoadSound ("animates_shield_clank1.mp3")
;camera
camera = CreateCamera ()
PositionEntity camera,0,5,-15
;lights
light = CreateLight ()
While Not KeyHit (1)
If KeyDown (208) Then MoveEntity camera,0,0,-1
If KeyDown (200) Then MoveEntity camera,0,0,1
If KeyDown (203) Then MoveEntity camera,-1,0,0
If KeyDown (205) Then MoveEntity camera,1,0,0
If MouseDown (1) Then TurnEntity camera,0,1,0
If MouseDown (2) Then TurnEntity camera,0,-1,0
anim_Animates (animates,GetKey ())
UpdateWorld
RenderWorld
Flip
Wend
End
Function anim_Animates (ent, action)
ExtractAnimSeq (animates, 1,1) ;idle seq 2
ExtractAnimSeq (animates, 1,15) ;walk seq 3
ExtractAnimSeq (animates, 15, 25) ;chopping motion seq 4
ExtractAnimSeq (animates, 25, 37) ;forward poking motion seq 5
ExtractAnimSeq (animates, 37, 63) ;fancy swordwork seq 6
ExtractAnimSeq (animates, 63, 74) ;block seq 7
ExtractAnimSeq (animates, 74, 90) ;animates hit seq 8
ExtractAnimSeq (animates, 90, 115) ;death seq 9
Select action
Case 49 seq = 2
Case 50 seq = 3
Case 51 seq = 4
Case 52 seq = 5
Case 53 seq = 6
Case 54
seq = 7 ;block
DebugLog AnimSeq (ent)
PlaySound animates_clank1
Case 55 seq = 8
Case 56 seq = 9
Default
Return
End Select
Animate ent,1,.2,seq
End Function
p.s. the part Im stuck is where it says case 54 PlaySound animates_clank1, Id like it to play exactly on the models animation frame 70. Thanks! |
| ||
| think your making it harder than it is, simply do if animseq(entity) = animation ; if animtime(entity) = no ; frame number you want for sound playsound clank1 endif endif also when extracting an animation sequence give it a handle , makes it easier to know whats what then .eg walk = extractanimseq(animates, 1,15) |
| ||
| sorry, im a noob ;) thanks sinu! |
| ||
| you should have posted in the beginners then i would've known that you were a new coder :) |