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。

  • 相关阅读:
    【9018:2221】[伪模板]可持久化线段树
    【9018:2208】可持久化线段树2
    【9018:2207】可持久化线段树1
    【POJ2187】Beauty Contest
    2017/11/22模拟赛
    2017/11/3模拟赛
    [AtCoder 2702]Fountain Walk
    [AtCoder3856]Ice Rink Game
    20170910模拟赛
    20170906模拟赛
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2799736.html
Copyright © 2011-2022 走看看