When I load the Editor, with my Custom AActor Class, everything works fine. If I edit my BluePrint (based on this Class) by first time, its ok. But no mater what I Do, at the second try to compile, the editors crash.
Please tell me I´m doing something wrong for quick fix, because this is absolutely insupportable.
Here my Code:
Weather.h
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Actor.h"
#include "Weather.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class AWeather : public AActor
{
GENERATED_UCLASS_BODY()
/** Sun */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weather")
TSubobjectPtr<class UDirectionalLightComponent> Sun;
/** BaseSpeed */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weather")
float BaseSpeed;
/** SunAngle */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weather")
float SunAngle;
/** SunDirection */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weather")
float SunDirection;
/** SunInclination */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weather")
float SunInclination;
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallDawn();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallDay();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallMidDay();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallDusk();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallNight();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallMidNight();
UFUNCTION(BlueprintImplementableEvent, Category = "Weather")
void CallUpdateTimeOfDay();
void DefineTimeOfDay();
void Tick(float DeltaTime) OVERRIDE;
void OnConstruction(const FTransform& Transform) OVERRIDE;
float _MaxAngle;
float _SunAngleStart;
int32 _lastAngle;
FString _lastTimeOfDay;
};
Weather.cpp
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "Sky.h"
#include "Weather.h"
AWeather::AWeather(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
this->BaseSpeed = 15;
this->SunAngle = 0;
this->_MaxAngle = 360;
this->_SunAngleStart = -90;
this->Sun = PCIP.CreateDefaultSubobject<UDirectionalLightComponent>(this, TEXT("DirectionalLightComponent"));
}
void AWeather::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
this->SunAngle = this->SunAngle + (DeltaTime * this->BaseSpeed);
FRotator Rotator = FRotator::ZeroRotator;
Rotator.Add(this->SunAngle - this->_SunAngleStart, this->SunDirection, this->SunInclination);
this->Sun->SetWorldRotation(Rotator);
if (this->SunAngle >= 360)
{
this->SunAngle = 0;
}
if (_lastAngle != floor(this->SunAngle)) {
CallUpdateTimeOfDay();
_lastAngle = floor(this->SunAngle);
}
DefineTimeOfDay();
}
void AWeather::DefineTimeOfDay()
{
if (SunAngle >= 0 && SunAngle < 75 && _lastTimeOfDay != "midnight")
{
CallMidNight();
_lastTimeOfDay = "midnight";
}
else if (SunAngle >= 75 && SunAngle < 90 && _lastTimeOfDay != "dawn")
{
CallDawn();
_lastTimeOfDay = "dawn";
}
else if (SunAngle >= 90 && SunAngle < 180 && _lastTimeOfDay != "day")
{
CallDay();
_lastTimeOfDay = "day";
}
else if (SunAngle >= 180 && SunAngle < 255 && _lastTimeOfDay != "midday")
{
CallMidDay();
_lastTimeOfDay = "midday";
}
else if (SunAngle >= 255 && SunAngle < 270 && _lastTimeOfDay != "dusk")
{
CallDusk();
_lastTimeOfDay = "dusk";
}
else if (SunAngle >= 270 && SunAngle < 360 && _lastTimeOfDay != "night")
{
CallNight();
_lastTimeOfDay = "night";
}
}
void AWeather::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
PrimaryActorTick.bCanEverTick = true;
Sun->SetRelativeScale3D(FVector(2.5f, 2.5f, 2.5f));
RootComponent = Sun;
FRotator Rotator = FRotator::ZeroRotator;
Rotator.Add(this->SunAngle - this->_SunAngleStart, this->SunDirection, this->SunInclination);
this->Sun->SetWorldRotation(Rotator);
}