Skip to content

Commit

Permalink
Remove grunt play sound
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaer Kazmer committed Aug 21, 2022
1 parent df1cbb2 commit 0b53161
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,52 +673,8 @@ export default e => {
using = e.use;
});

let animationOffset={
'swordSideSlash':350,
'swordSideSlashStep':150,
'swordTopDownSlash':100,
'swordTopDownSlashStep':150
}
let startAnimationTime=0;
let playSoundSw=false;
let lastPlaySoundAnimationIndex = null;
useFrame(() => {
const localPlayer = useLocalPlayer();
if(localPlayer.avatar && wearing){
if(localPlayer.avatar.useAnimationIndex >= 0 && localPlayer.avatar.useAnimationIndex !== lastPlaySoundAnimationIndex){
if(startAnimationTime===0){
startAnimationTime=performance.now();
}
if(
performance.now()-startAnimationTime>=animationOffset[localPlayer.avatar.useAnimationCombo[localPlayer.avatar.useAnimationIndex]]
&& !playSoundSw
){
const indexOfSlash=localPlayer.avatar.useAnimationIndex;
sounds.playSound(soundFiles.combat[soundIndex+(4*indexOfSlash+Math.floor(Math.random()*4))]);
localPlayer.characterSfx.playGrunt('attack');
playSoundSw=true;
lastPlaySoundAnimationIndex = localPlayer.avatar.useAnimationIndex;
}
}
else{
playSoundSw=false;
startAnimationTime=0;
}
if (!(localPlayer.avatar.useAnimationIndex >= 0)) lastPlaySoundAnimationIndex = null;
}
/* if (!wearing) {
if (subApp) {
subApp.position.copy(app.position);
subApp.quaternion.copy(app.quaternion);
subApp.updateMatrixWorld();
}
} else {
if (subApp) {
app.position.copy(subApp.position);
app.quaternion.copy(subApp.quaternion);
app.updateMatrixWorld();
}
} */

if (trailMesh && subApp) {
trailMesh.update(using, subApp.matrixWorld);
Expand All @@ -742,4 +698,4 @@ export default e => {
app.getPhysicsObjects = () => subApp ? subApp.getPhysicsObjects() : [];

return app;
};
};

0 comments on commit 0b53161

Please sign in to comment.