UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a weather system"
UWeatherSystem::UWeatherSystem() { // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; // Set the default weather type CurrentWeatherType = EWeatherType::Sunny; } void UWeatherSystem::BeginPlay() { Super::BeginPlay(); // Apply the default weather type ApplyWeatherEffects(CurrentWeatherType); } void UWeatherSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // Check if the weather type has changed if (CurrentWeatherType != TargetWeatherType) { // Fade out the current weather effects FadeOutWeatherEffects(DeltaTime); // When the fade out is complete, apply the new weather type if (WeatherFadeTimer <= 0.0f) { CurrentWeatherType = TargetWeatherType; ApplyWeatherEffects(CurrentWeatherType); } } } void UWeatherSystem::SetWeatherType(EWeatherType NewWeatherType) { TargetWeatherType = NewWeatherType; WeatherFadeTimer = WeatherFadeTime; }