zoukankan      html  css  js  c++  java
  • UE4

    #include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"
    
    //省略大部分代码
    void AMyFPS_Character::OnMoveingOrRot()
    {
        GetActorLocation();
        //LineTraceSingle_NEW();
        if (GEngine != nullptr)
        {
            FHitResult hit;
            auto temp_startPos = GetActorLocation();
            auto temp_rota = GetActorRotation();
    
            auto temp_endPos = FRotationMatrix(temp_rota).GetScaledAxis(EAxis::X) * 500.0f; // + 
            //hit.
            m_bodyInstance.LineTrace(hit, temp_startPos, temp_endPos, false, false);
            if (hit.Actor != nullptr && hit.Actor != this)
            {
                m_operaTarget = hit.Actor;
            }
        }
    }

    //Exa 2
    //In player controller class
     
    //location the PC is focused on
    const FVector Start = GetFocalLocation(); 
     
    //256 units in facing direction of PC (256 units in front of the camera)
    const FVector End = Start + GetControlRotation().Vector() * 256; 
     
    //The trace data is stored here
    FHitResult HitData(ForceInit);
     
    //If Trace Hits anything
    if(  UMyStaticFunctionLibrary::Trace(GetWorld(),GetPawn(),Start,End,HitData)  )
    {
    	//Print out the name of the traced actor
    	if(HitData.GetActor())
    	{
    		ClientMessage(HitData.GetActor()->GetName());
     
    	        //Print out distance from start of trace to impact point
    	        ClientMessage("Trace Distance: " + FString::SanitizeFloat(HitData.Distance));
    	}
    }
     
  • 相关阅读:
    2019JAVA第三次实验报告
    第二次作业
    第一周作业
    2019年春总结
    第二周作业
    第十二周作业
    第十一周作业
    第十周作业
    第九周作业
    第八周作业
  • 原文地址:https://www.cnblogs.com/linqing/p/5029914.html
Copyright © 2011-2022 走看看