• BeamTarget红外线的末尾


      1.红外线一直穿透面让人十分的苦恼,我得想办法让红外线检测到碰撞物体,想到了LinkGun的Beam子弹,这种粒子是红外线检测的重要内容,该粒子的编辑器里面能获取他的End Point name

    var ParticleSystem BeamParticleTemplate;
    //末尾的名字
    var Name BeamParticleEndPointParameterName;
    
    var vector BeamParticleTranslationOffset;
    
    var ParticleSystemComponent BeamParticleSystemComponent;

      a..粒子和其Component

      b..粒子的末尾信息参数名字,粒子的位置信息(用于标记结尾)

      

      2.beam的起始点当然是其开火位置MuzzleFlashPoint,那么结尾位置怎么检测呢?如果解决了这一问题,红外线的碰撞检测问题就迎刃而解!

    //Trace记录
    local vector StartTrace,EndTrace;
    //获取枪口的位置
    local name SocketName;
    local Vector SocketLocation;
    local rotator SocketRotation;
    
    
    SkeletalMeshComponent.GetSocketWorldLocationAndRotation(SocketName,SocketLocation,SocketRotation);
    
    StartTrace=SocketLocation;
    EndTrace=SocketLocation+vector(SocketRotation)*TraceRange;

      3.BeamParticle的连接方式

    if(BeamParticleSystemComponent==none&&BeamParticleTemplate!=none)
    {
         BeamParticleSystemComponent=new() class'ParticleSystemComponent'
         if(BeamParticleSystemComponent!=none)
        {
             BeamParticleSystemComponent.SetTemplate(BeamParticleTemplate);
             BeamParticleSystemComponent.SetTranslation(BeamParticleTranslationOffset);
    
              if(SkeletalMeshComponent!=none&&SkeletalMeshComponent.GetSocketByName('MussleFlashSocket'!=none)
              {
                   SkeletalMeshComponent.AttachComponentToSocket(BeamParticleSystemComponent,MuzzleSocketEffectName);
              }
        }
    }

      上边进行了连接,下边激活之。

    if(BeamParticleSystemComponent!=none)
    {
         BeamParticleSystemComponent.ActivateSystem();
         BeamParticleSystemComponetn.SetVectorParameter(BeamParticleEndPointParameterName,(!IsZero(HitLocation))?HitLocation:EndTrace);
    }

      若不想激活,灭之。

    simulated function StopFiringEffects()
    {
         if(BeamParticleSystemComponent!=none)
         {
               BeamParticleSystemComponent.DeactivateSystem();
         }
    }

       这里我将写一个UpdateBeam函数来不断地刷新Beam的末尾位置。同时我还要写一个Trace获取HitLocation。

  • 相关阅读:
    【转】ubuntu 13.04 普通用户丢失sudo权限后的恢复办法
    #流水账# Mac上用Virtualbox安装//配置虚拟机Ubuntu
    #小知识# 网页内容居中的办法
    无法正常访问FTP服务(Windows 7 + VirtualBox + Ubuntu + vsftpd)
    【转】WordPress上传主题出错:无法创建目录
    判断是PC端还是移动端
    公告滚动
    vs code 汉化 自动保存 插件
    手机端的适配
    css 常见属性
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2799736.html
Copyright © 2020-2023  润新知