お世話になっております。
miyayukです。
表題のSetWeaponAmbientSound()の使い方について質問させてください。
実現したいのはLinkPlasmaのビームタイプのように
ボタン押下時にforeverのサウンドを再生して
ボタンを離すとサウンドが停止するような感じです。
基本ベースはPlatformerKitで作成しており
SPG_Weaponクラスに以下のstateを追加して
UTBeamWeaponと同じようにサウンド部分を実装しているのですが
実際に音が再生されない状態です。
具体的にはBeginState / EndState部分にサウンド部分を追加しております。
※defaultproperties部分は省略してます
※SPG_PlayerPawnにSetWeaponAmbientSound部分は組み込んで おります
※実際はSPG_から始まる名前ではなく、ActTwoSide_から始まる名前でucファイルを作成して おります
(分かり難くしててすみません。。)
どこかおかしな点などわかる方いましたら返信頂けると幸いです。Code:/********************************************************************************************* * state WeaponFiring * This is the default Firing State. It's performed on both the client and the server. *********************************************************************************************/ simulated state WeaponFiring { simulated event bool IsFiring() { return true; } /** * Timer event, call is set up in Weapon::TimeWeaponFiring(). * The weapon is given a chance to evaluate if another shot should be fired. * This event defines the weapon's rate of fire. */ simulated function RefireCheckTimer() { // if switching to another weapon, abort firing and put down right away if( bWeaponPutDown ) { `LogInv("Weapon put down requested during fire, put it down now"); PutDownWeapon(); return; } // If weapon should keep on firing, then do not leave state and fire again. if( ShouldRefire() ) { FireAmmunition(); return; } // Otherwise we're done firing HandleFinishedFiring(); } simulated event BeginState( Name PreviousStateName ) { local ActTwoSide_PlayerPawn POwner; POwner = ActTwoSide_PlayerPawn(Instigator); if (POwner != None) { POwner.SetWeaponAmbientSound(StartAltFireSound); } `LogInv("PreviousStateName:" @ PreviousStateName); // Fire the first shot right away FireAmmunition(); TimeWeaponFiring( CurrentFireMode ); //Instigator.PlaySound(EndAltFireSound); } simulated event EndState( Name NextStateName ) { local ActTwoSide_PlayerPawn POwner; POwner = ActTwoSide_PlayerPawn(Instigator); if (POwner != None) { POwner.SetWeaponAmbientSound(None); } `LogInv("NextStateName:" @ NextStateName); // Set weapon as not firing ClearFlashCount(); ClearFlashLocation(); ClearTimer( nameof(RefireCheckTimer) ); NotifyWeaponFinishedFiring( CurrentFireMode ); //Instigator.PlaySound(None); } } defaultproperties { // Set the weapon firing states FiringStatesArray(0)="WeaponFiring" // Set the weapon to fire projectiles by default WeaponFireTypes(0)=EWFT_Projectile }



Reply With Quote


Bookmarks