When I try to start the project it crashes.
On crash report below it says line 30 but there is nothing on line 30.
There was a code but i deleted it after the first crash. It was
Value = CrouchCurve->GetFloatValue(ElapsedTime);
#include "PlayerCharacter.h"
#include "Camera/CameraComponent.h"
#include "GameFrameWork/SpringArmComponent.h"
#include "GameFrameWork/CharacterMovementComponent.h"
// Sets default values
APlayerCharacter::APlayerCharacter()
{
// 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;
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComp"));
CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));
SpringArmComp->SetupAttachment(GetMesh());
CameraComp->SetupAttachment(SpringArmComp, USpringArmComponent::SocketName);
CameraComp->SetRelativeLocation(CameraLocation);
SpringArmComp->bUsePawnControlRotation = true;
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->bUseControllerDesiredRotation = true;
GetCharacterMovement()->bIgnoreBaseRotation = true;
}
// Called when the game starts or when spawned
void APlayerCharacter::BeginPlay()
{
Super::BeginPlay();
IsCrouched = false;
}
void APlayerCharacter::MoveForward(float InputAxis)
{
if ((Controller != nullptr) && (InputAxis != 0.0f))
{
// Which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// Get forward vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, InputAxis);
}
}
void APlayerCharacter::MoveRight(float InputAxis)
{
if ((Controller != nullptr) && (InputAxis != 0.0f))
{
// Which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// Get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
AddMovementInput(Direction, InputAxis);
}
}
void APlayerCharacter::ToggleCrouch()
{
float CrouchVectorZ = 0.0f;
ElapsedTime > 1.0f ? ElapsedTime = 0 : ElapsedTime = 1 - ElapsedTime;
if (IsCrouched)
{
Crouch();
//CrouchVectorZ = CrouchCurve->GetFloatValue(ElapsedTime);
}
else
{
UnCrouch();
//CrouchVectorZ = UnCrouchCurve->GetFloatValue(ElapsedTime);
}
CameraLocation = FVector(0, 50, CrouchVectorZ);
IsCrouched = !IsCrouched;
}
// Called every frame
void APlayerCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ElapsedTime += DeltaTime;
}
// Called to bind functionality to input
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &APlayerCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &APlayerCharacter::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAction("Crouch", IE_Pressed, this, &APlayerCharacter::ToggleCrouch);
//PlayerInputComponent->BindAction("Sprint", IE_Pressed, this, &APlayerCharacter::ToggleSprint);
//PlayerInputComponent->BindAction("Walk", IE_Pressed, this, &APlayerCharacter::ToggleWalk);