无法生成静态网格物体组件

时间:2019-01-20 14:44:41

标签: c++ unreal-engine4

我正在尝试生成网格,但没有任何反应。甚至没有编译错误。起初,虚幻找不到路径。 ((“” /Game/Models-Textures/StaticMeshes/Plane_64x64.uasset“)

所以我什至无法打开虚幻的东西。现在已经以某种方式修复了它,我可以毫无错误地对其进行编译,但是我无法使其正常工作。帮助。

我不知道仍然是因为路径,所以这是具有Plane_64x64 F:\UE_projects\GridGame\Content\Models-Textures\StaticMeshes

的文件夹
#include "GridGenerator.h"
#include "Components/StaticMeshComponent.h"
#include "ConstructorHelpers.h"
// Sets default values
AGridGenerator::AGridGenerator()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = false;
    size = 16;
    sum = size * size;
    offsetAmount = 65;

    for (int i = 0; i < sum; i++) {
        if (sum % size == 0) {
            FVector temp;
            temp.X = sum+offsetAmount;
            temp.Y = offsetAmount;
            temp.Z = 0;
            offsetVector = offsetVector+temp;

            Mesh = SpawnMesh(offsetVector);
            ReactiveFloor(worldLocation);

            MeshArray[i] = Mesh;

            offsetVector.X = offsetVector.X + offsetAmount;
        }
        else {
            Mesh = SpawnMesh(offsetVector);
            ReactiveFloor(worldLocation);

            MeshArray[i] = Mesh;

            offsetVector.X = offsetVector.X + offsetAmount;
        }
    }
}

UStaticMeshComponent* AGridGenerator::SpawnMesh(FVector offsetVector)
{
    UStaticMeshComponent* Grid = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Grid"));
    Grid->SetupAttachment(RootComponent);

    static ConstructorHelpers::FObjectFinder<UStaticMesh>GridAsset(TEXT("/Game/Models-Textures/StaticMeshes/Plane_64x64"));

    Grid->SetStaticMesh(GridAsset.Object);
    Grid->SetRelativeLocation(offsetVector);
    Grid->SetWorldScale3D(FVector(1.f));
    worldLocation = offsetVector;
    return Grid;
}*/

void AGridGenerator::ReactiveFloor(FVector worldLocation) {
    FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
    RV_TraceParams.bTraceComplex = true;
    RV_TraceParams.bTraceAsyncScene = true;
    RV_TraceParams.bReturnPhysicalMaterial = false;

    //Re-initialize hit info
    FHitResult RV_Hit(ForceInit);

    //call GetWorld() from within an actor extending class
    GetWorld()->LineTraceSingleByChannel(RV_Hit, worldLocation + (FVector(0, 0, 2000)), worldLocation - (FVector(0, 0, 2000)), ECC_EngineTraceChannel1);
    FVector temp2;
    temp2.X = worldLocation.X;
    temp2.Y = worldLocation.Y;
    temp2.Z = RV_Hit.ImpactPoint.Z;
    FRotator tempR;
    tempR.Pitch = (RV_Hit.ImpactNormal.X * 45);
    tempR.Roll = (RV_Hit.ImpactNormal.Y * 45);

    SetActorLocationAndRotation(temp2, tempR);
}

0 个答案:

没有答案