We don't keep the index buffer CPU accessible outside the editor, to save memory.
GetArrayView is returning incorrect values in Standalone games. The correct values are returned when played in Editor.
public:
UFUNCTION(BlueprintCallable, Category = Selection)
void Raycast();
#include "GameFramework/PlayerController.h" #include "Runtime/Engine/Public/StaticMeshResources.h" #include "RayCastTest1Character.h" // ... void AMyPlayerController::Raycast() { FVector MousePos; FVector MouseDir; FRotator Rot; DeprojectMousePositionToWorld(MousePos, MouseDir); FHitResult RV_Hit(ForceInit); FCollisionResponseParams parms; FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true); FVector Start = MousePos; FVector End = MousePos + (MouseDir * 200000); RV_TraceParams.bReturnFaceIndex = true; RV_TraceParams.bTraceComplex = true; for (TActorIterator<ARayCastTest1Character> ActorItr(GetWorld()); ActorItr; ++ActorItr) { RV_TraceParams.AddIgnoredActor(*ActorItr); } DrawDebugLine(GetWorld(), Start, End, FColor(255, 0, 0), true, 10, 0, 1); bool DidTrace = GetWorld()->LineTraceSingle(RV_Hit, Start, End, ECollisionChannel::ECC_WorldStatic, RV_TraceParams); if (!DidTrace) { return; } const auto* Actor = RV_Hit.GetActor(); AStaticMeshActor* aactor = (AStaticMeshActor*)Actor; UStaticMeshComponent* HitStaticMeshComponent = aactor->StaticMeshComponent; FString stxt = Actor->GetActorClass()->GetName(); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, stxt); if (HitStaticMeshComponent) { UStaticMesh* StaticMesh = HitStaticMeshComponent->StaticMesh; FStaticMeshLODResources& LODModel = StaticMesh->RenderData->LODResources[0]; FIndexArrayView Indices = LODModel.IndexBuffer.GetArrayView(); bool bDebug = true; } }
PlayerControllerClass = AMyPlayerController::StaticClass();
RESULTS:
The values shown for Indices are incorrect.
EXPECTED:
The values shown for Indices are the same as they were when playing in the Editor.
I am not able to find world outliner how to enable it?
How can i modify the param name in EQS node
Bullet replication problem. The players sees each other but does not see the bullet
When I open UE4 4.24.3 it appears that. Does anyone know how to solve?
Undefined sysmbol: typeinfo for AActor when cross-compile linux dedicated server on windows
Hey, why do i get this when i snap two similar meshes together?
Head over to the existing Questions & Answers thread and let us know what's up.
0 |
Component | UE - Gameplay |
---|---|
Affects Versions | 4.7 |
Created | Nov 14, 2014 |
---|---|
Resolved | Nov 25, 2014 |
Updated | Apr 27, 2018 |