Download

Engine Crashes whenever I attempt to select and move a character

Currently I a struggling with a bug that’s preventing me from properly debugging my game. My main character can not be move or edited within the editor without causing an exception to be thrown and the engine crashing. I believe its a result of the actor component I have made and attached to with a cleaner amount of information here: Engine Crashes attempt to edit actor component in a scene - UE4 AnswerHub

Whenever I attempt to make a BoxComponent not HiddenInGame within the editor it throws this access violation exception

Exception thrown at 0x00007FF951F15502 (UE4Editor-Renderer.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000040.

In BasePassRendering.cpp at this location

  1. void FBasePassMeshProcessor::AddMeshBatch(const FMeshBatch& RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, int32 StaticMeshId)
  2. {
  3. if (MeshBatch.bUseForMaterial)
  4. {
  5. // Determine the mesh’s material and blend mode.
  6. const FMaterialRenderProxy* FallbackMaterialRenderProxyPtr = nullptr;
  7. const FMaterial& Material = MeshBatch.MaterialRenderProxy->GetMaterialWithFallback(FeatureLevel, FallbackMaterialRenderProxyPtr);

The component in question is called a UCameraBoundingBoxComponent and is a child of UActorComponent ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)

  1. ASSDCharacter::ASSDCharacter(const FObjectInitializer& ObjectInitializer)
  2. : ACharacter(ObjectInitializer.SetDefaultSubobjectClass<USSDPlayerMovementComponent>(ACharacter::CharacterMovementComponentName))
  3. {
  4. CameraBounds = CreateDefaultSubobject<UCameraBoundingBoxComponent>(TEXT(“CameraBounds”));
  5. verify(CameraBounds != nullptr);
  6. }

I was creating a camera bounding box as an actor component so I could use it with multiple characters. This seemed like the perfect time to abstract the camera logic from the player

The actor component also has other components as well to handle the camera logic. I can have it inherit from the three I guess, I just wanted a separate camera component and logic

  1. UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
  2. class SIDESCROLLINGDEMO_API UCameraBoundingBoxComponent : public UActorComponent
  3. {
  4. GENERATED_BODY()
  5. public:
  6. // Sets default values for this component’s properties
  7. UCameraBoundingBoxComponent();
  8. protected:
  9. UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = “CameraBounds”, meta = (AllowPrivateAccess = “true”))
  10. class UCameraComponent* CameraComponent;
  11. UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = “CameraBounds”, meta = (AllowPrivateAccess = “true”))
  12. class UBoxComponent* BoundingBox;
  13. UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = “CameraBounds”, meta = (AllowPrivateAccess = “true”))
  14. class UStaticMeshComponent* ViewPlane;

In the actor component constructor

  1. UCameraBoundingBoxComponent::UCameraBoundingBoxComponent()
  2. {
  3. // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
  4. // off to improve performance if you don’t need them.
  5. PrimaryComponentTick.bCanEverTick = true;
  6. BoundingBox = CreateDefaultSubobject<UBoxComponent>(TEXT(“Bounds”));
  7. BoundingBox->SetRelativeLocation(FVector(0.f, 0.f,0.f));
  8. BoundingBox->InitBoxExtent(MainBoxSize);
  9. BoundingBox->SetUsingAbsoluteLocation(true);
  10. BoundingBox->SetUsingAbsoluteRotation(true);
  11. }