Add Sin wave to Light Brightness
This commit is contained in:
parent
f1c2ac0ec6
commit
797f4def89
|
@ -18,9 +18,8 @@ AWeaponPickup::AWeaponPickup()
|
|||
SphereComponent->SetupAttachment(RootComponent);
|
||||
|
||||
PointLightComponent = CreateDefaultSubobject<UPointLightComponent>(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,
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue