zoukankan      html  css  js  c++  java
  • 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。

  • 相关阅读:
    项目管理【38】 | 项目人力资源管理-管理项目团队
    转:模型蒸馏,教师学生模型
    转:pytorch 中forward 的用法与解释说明
    KNN, sklearn
    转:matplotlib, 去除plt.savefig()的白边
    转:Latex 表格 合并行/列
    转:LaTeX xcolor颜色介绍
    余弦相似性,cos距离函数
    python confusion matrix 混淆矩阵
    转:Tmux 使用教程
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2799736.html
Copyright © 2011-2022 走看看