diff --git a/Source/Nakatomi/WeaponPickup.cpp b/Source/Nakatomi/WeaponPickup.cpp index f7125b3..a17cbb6 100644 --- a/Source/Nakatomi/WeaponPickup.cpp +++ b/Source/Nakatomi/WeaponPickup.cpp @@ -18,9 +18,8 @@ AWeaponPickup::AWeaponPickup() SphereComponent->SetupAttachment(RootComponent); PointLightComponent = CreateDefaultSubobject(TEXT("PointLightComponent")); - PointLightComponent->SetLightColor(FLinearColor::White); + PointLightComponent->SetLightColor(FLinearColor::FromSRGBColor(LightColor)); PointLightComponent->SetupAttachment(RootComponent); - } // Called when the game starts or when spawned @@ -34,6 +33,7 @@ void AWeaponPickup::BeginPlay() } SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &AWeaponPickup::OnOverlapBegin); + PointLightComponent->SetWorldLocation(this->GetActorLocation()); } // Called every frame @@ -51,6 +51,10 @@ void AWeaponPickup::Tick(float DeltaTime) float Sine = FMath::Sin(Time * MovementSpeed); WeaponComponent->SetActorLocation(WeaponStartingLocation + ((MovementDirection * Sine) * MovementDistance)); } + + PointLightComponent->MarkRenderStateDirty(); // We have to do this because Unreal doesn't like it when you create lights in c++ apparently ::pain:: + float sin = FMath::Abs(FMath::Sin(GetWorld()->GetRealTimeSeconds() * (MovementSpeed / 2))); + PointLightComponent->SetLightBrightness(sin * MaxLightBrightness); } void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, diff --git a/Source/Nakatomi/WeaponPickup.h b/Source/Nakatomi/WeaponPickup.h index 49f6fe8..c0e1c4f 100644 --- a/Source/Nakatomi/WeaponPickup.h +++ b/Source/Nakatomi/WeaponPickup.h @@ -35,6 +35,12 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) float RotationSpeed = 50.0f; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + float MaxLightBrightness = 5000.0f; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + FColor LightColor = FColor::White; + private: UPROPERTY()