Add ToggleLight class to trigger lights in radius
+ Followed UE4 tutoial on mixing C++ and Blueprints + https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ClassCreation/CodeAndBlueprints/ + Added an in-editor and blueprint field ToggleLight::Radius to adjust trigger radius + Made stairs light up as you walk up them
This commit is contained in:
53
Source/ThirdPerson/Public/ToggleLight.h
Normal file
53
Source/ThirdPerson/Public/ToggleLight.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// All content (c) Shaun Reed 2021, all rights reserved
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "ToggleLight.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class THIRDPERSON_API AToggleLight : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AToggleLight();
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Switch Components")
|
||||
class UPointLightComponent* PointLight1;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Switch Components")
|
||||
class USphereComponent* Sphere1;
|
||||
|
||||
// Radius of the trigger to toggle the light
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch Variables")
|
||||
float Radius = 50.0f;
|
||||
|
||||
/** the desired intensity for the light */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch Variables")
|
||||
float DesiredIntensity;
|
||||
|
||||
/** Toggles the light component's visibility*/
|
||||
UFUNCTION()
|
||||
void ToggleLight();
|
||||
|
||||
//
|
||||
// Trigger functions
|
||||
|
||||
/** called when something enters the sphere component */
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Switch Functions")
|
||||
void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||
void OnOverlapBegin_Implementation(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||
|
||||
/** called when something leaves the sphere component */
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Switch Functions")
|
||||
void OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
|
||||
void OnOverlapEnd_Implementation(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
|
||||
|
||||
//
|
||||
// Update functions
|
||||
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
};
|
||||
Reference in New Issue
Block a user