我常常想偷懒,说iOS游戏不需要复杂的脚步声。一种万年音便可以搞定玩家的视听感受,然而我制作了一个河道关卡,玩家需要涉水而过。这让我不得不改变原有的预期制作水花和踩水的声音。
事已至此我就是用虚幻的PhysicalMaterialPropertyBase来解决这个问题。
class AntPhysicalMaterialProperty extends PhysicalMaterialPropertyBase collapsecategories editinlinenew hidecategories(Object); var(Sounds) const SoundCue FootStepSoundCue;
var name materialType; //别急,我们一会儿新建一个类叫做AntPawnSoundGroup,并且在AntPawn中引用
我们看到了物理材质中有一个脚步音,这是解决问题的关键。
1.打开虚幻编辑器,新建一个PhysicalMaterial。然后在
}
static function SoundCue GetFootstepSound(int FootDown, name MaterialType)
{ local int i;
i = default.FootstepSounds.Find('MaterialType', MaterialType); return (i == -1 || MaterialType=='') ? default.DefaultFootstepSound : default.FootstepSounds[i].Sound; // checking for a '' material in case of empty array elements
}
//在Defaultproperties中有以下分类
FootstepSounds[0]=(MaterialType=Stone,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_StoneCue')
FootstepSounds[1]=(MaterialType=Dirt,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_DirtCue')
FootstepSounds[2]=(MaterialType=Energy,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_EnergyCue')
FootstepSounds[3]=(MaterialType=Flesh_Human,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_FleshCue')
FootstepSounds[4]=(MaterialType=Foliage,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_FoliageCue')
FootstepSounds[5]=(MaterialType=Glass,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_GlassPlateCue')
FootstepSounds[6]=(MaterialType=Water,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_WaterDeepCue')
FootstepSounds[7]=(MaterialType=ShallowWater,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_WaterShallowCue')
FootstepSounds[8]=(MaterialType=Metal,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_MetalCue')
FootstepSounds[9]=(MaterialType=Snow,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_SnowCue')
FootstepSounds[10]=(MaterialType=Wood,Sound=SoundCue'A_Character_Footsteps.FootSteps.A_Character_Footstep_WoodCue')
3.在Pawn中我们设定该变量,并且
var class<AntPawnSoundGroup> SoundGroupClass;
SoundGroupClass=class'AntGame.AntPawnSoundGroup'
4.第四步在你的材质中设置PhysicsMaterial
5.最重要的一步在这里,我给你关键词你直接去找吧
PlayFootStepSound() //为了避免第一人称处理
ActuallyPlayFootStepSound //在这里调用了AntSoundGroup
GetMaterialBlewFoot() //怎么获取材质的重要函数。
完~