Static mesh component


Here is what I am trying to achieve:

I want to make a c++ class, which defines my player. I want to be able to add it to my scene through a blueprint based from this class, and to tweak the defaults values written in my c++ file in the blueprint defaults. Currently I can select my static mesh in the defaults through the blueprint editor, but whenever I click on the mesh in the viewport (in game), the editor crashes.

I have got three questions according to my issue:

  • Why does it crash?
  • Is there a way
    to “reinit” the blueprint instead of
    deleting it and creating it again when I add
    components in the c++ class constructor?
  • Why is
    my compiling so slow when I only add
    1 line in my .cpp file? (taking up to 40 seconds atm!)


// Fill out your copyright notice in the Description page of Project Settings.

#include "RollGame.h"
#include "Ball.h"

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

	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
	CameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
	CameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f,50.0f), FRotator(-60.0f, 0.0f, 0.0f));
	CameraSpringArm->TargetArmLength = 400.0f;
	CameraSpringArm->bEnableCameraLag = true;
	CameraSpringArm->CameraLagSpeed = 3.0f;

	Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera"));
	Camera->AttachTo(CameraSpringArm, USpringArmComponent::SocketName);

	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BallMesh"));
	AutoPossessPlayer = EAutoReceiveInput::Player0;

void ABall::PostInitializeComponents()

// Called when the game starts or when spawned
void ABall::BeginPlay()

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



// Called to bind functionality to input
void ABall::SetupPlayerInputComponent(class UInputComponent* InputComponent)

	InputComponent->BindAxis("ForwardAxis", this, &ABall::MoveForward);
	InputComponent->BindAxis("RightAxis", this, &ABall::MoveRight);

void ABall::MoveForward(float AxisValue){
	MovementInput.X = FMath::Clamp<float>(AxisValue, -1.0f, 1.0f);

void ABall::MoveRight(float AxisValue){
	MovementInput.Y = FMath::Clamp<float>(AxisValue, -1.0f, 1.0f);


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Pawn.h"
#include "Ball.generated.h"

class ROLLGAME_API ABall : public APawn

	// Sets default values for this pawn's properties

	virtual void PostInitializeComponents() override;

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

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

	USpringArmComponent* CameraSpringArm;
	UCameraComponent* Camera;
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
	UStaticMeshComponent* StaticMesh;

	FVector2D MovementInput;

	void MoveForward(float AxisValue);
	void MoveRight(float AxisValue);

Here is the crash report:

"Assertion failed: !bRegistered || AttachParent->AttachChildren.Contains(this) [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.8\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp] [Line: 1335] 
Attempt to detach SceneCompon

Ask me if you need more details, or some screens.

Have a nice day!