zoukankan      html  css  js  c++  java
  • 物理材质脚步声音

      我常常想偷懒,说iOS游戏不需要复杂的脚步声。一种万年音便可以搞定玩家的视听感受,然而我制作了一个河道关卡,玩家需要涉水而过。这让我不得不改变原有的预期制作水花和踩水的声音。

      事已至此我就是用虚幻的PhysicalMaterialPropertyBase来解决这个问题。

    class AntPhysicalMaterialProperty extends PhysicalMaterialPropertyBase
      collapsecategories
      editinlinenew
      hidecategories(Object);
    
    var(Sounds) const SoundCue FootStepSoundCue;
    var name materialType; //别急,我们一会儿新建一个类叫做AntPawnSoundGroup,并且在AntPawn中引用
      
      我们看到了物理材质中有一个脚步音,这是解决问题的关键。

    1.打开虚幻编辑器,新建一个PhysicalMaterial。然后在
    选项中拉下,将会出现刚才的AntPhysicalMaterialProperty类。
     
     
      2.建立一个AntPawnSoundGroup,这里面存储声音。你的角色被打到,摔下去,中弹,被淹死。能想到的功能都给他能上~
    由于我的好心,就给你剥离出来最重要的内容,我们只需要根据材质辨别脚步声,
     
     struct FootStepSoundInfo
    {
        var name MaterialType;
                var SoundCue Sound;
    }
     紧接着建立一个结构数组
      var array<FootStepSoundInfo> FootStepSounds;
      var Soundcue defaultFootStepSound;
     

    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()  //怎么获取材质的重要函数。

    完~

     
     
     
     
     
     
     
     
      
      
      
      
  • 相关阅读:
    oracle 导入数据时提示只有 DBA 才能导入由其他 DBA 导出的文件
    oracle 常用语句
    android udp 无法收到数据 (模拟器中)
    android DatagramSocket send 发送数据出错
    AtCoder ABC 128E Roadwork
    AtCoder ABC 128D equeue
    AtCoder ABC 127F Absolute Minima
    AtCoder ABC 127E Cell Distance
    CodeForces 1166E The LCMs Must be Large
    CodeForces 1166D Cute Sequences
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/3504414.html
Copyright © 2011-2022 走看看