x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Camera Component Crash

Im having an issue with my code for the camera crashing my Unreal Editor. I was able to compile the camera component and test. Once I setup the springarm component, it broke my camera component code somewhere. I had to delete all the files in my Binary/64 folders and that didnt work. I commented out all the spring arm code and that didnt work. Only when I commented out all the camera code was i able to get the project to get past 71% and open. Here is the code. If there is anything you can see that might be causing it I'd be grateful.

----------------.h file----------------------- #pragma once

include "CoreMinimal.h"

include "GameFramework/Character.h" #include "SCharacter.generated.h"

//class UCameraComponent;

UCLASS() class SILENTRED_API ASCharacter : public ACharacter { GENERATED_BODY()

public: // Sets default values for this character's properties ASCharacter();

protected: // Called when the game starts or when spawned virtual void BeginPlay() override;

 void MoveForward(float Value);
 void MoveRight(float Value);
 
 //UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
 //UCameraComponent* CameraComp;

 //UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
 //USpringArmComponent* SpringArmComp;

public:
// Called every frame virtual void Tick(float DeltaTime) override;

 // Called to bind functionality to input
 virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

}; -------------.CPP file----------- #include "SCharacter.h" //#include "Camera/CameraComponent.h"

// Sets default values ASCharacter::ASCharacter() { // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true;

 //CameraComp->bUsePawnControlRotation = true;
 

 //CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));
 

}

// Called when the game starts or when spawned void ASCharacter::BeginPlay() { Super::BeginPlay();

}

void ASCharacter::MoveForward(float Value) { AddMovementInput(GetActorForwardVector() * Value); }

void ASCharacter::MoveRight(float Value) { AddMovementInput(GetActorRightVector() * Value); }

// Called every frame void ASCharacter::Tick(float DeltaTime) { Super::Tick(DeltaTime);

}

// Called to bind functionality to input void ASCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent);

 PlayerInputComponent->BindAxis("MoveForward", this, &ASCharacter::MoveForward);
 PlayerInputComponent->BindAxis("MoveRight", this, &ASCharacter::MoveRight);
 PlayerInputComponent->BindAxis("LookUp", this, &ASCharacter::AddControllerPitchInput);
 PlayerInputComponent->BindAxis("Turn", this, &ASCharacter::AddControllerYawInput);

}

Product Version: UE 4.19
Tags:
more ▼

asked Oct 15 '18 at 07:40 PM in C++ Programming

avatar image

Chaxshadow
1 1 1

avatar image Chaxshadow Oct 15 '18 at 07:59 PM

After Commenting Each line of camera code out one by one I figured out that
CameraComp->bUsePawnControlRotation = true; is causing the issues. Every time is compile in Visual Studio and it hot compiles in UR4 it crashes. I still do not know why this is happening so still looking for some direction please.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

the problem is in that code :

 CameraComp->bUsePawnControlRotation = true;
  
 CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));

you try to set a variable when the pointer is still null

and you asign it on the next line. So the fix would be to swap the line :

 CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));
 
 CameraComp->bUsePawnControlRotation = true;

 
more ▼

answered Oct 15 '18 at 08:10 PM

avatar image

Firefly74
1.5k 14 18 32

avatar image Chaxshadow Oct 16 '18 at 04:20 PM

I tried this but still get the crash at 71%. There is one thing I need to check before can say that this didnt work when I get home. I let you know the results.

avatar image Chaxshadow Oct 17 '18 at 12:44 PM

This did do the trick once I found out that it changed a controller setting in the blueprints. Once i was able to load the project and set it to default and swap the lines of code the crashing stopped and everything worked as is should. Thank you for your help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question