Using C++ in Unreal Engine 4 follow these steps https://docs.unrealengine.com/la
ID: 3835123 • Letter: U
Question
Using C++ in Unreal Engine 4 follow these steps https://docs.unrealengine.com/latest/INT/Programming/QuickStart/index.html and create a FloatingActor class. In addition, add a variable that can be edited in blueprints and the editor. Submit the cpp and h files of that class.
Adding variables to unreal editor
UCLASS()
class AMyActor : public AActor {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
int32 TotalDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
float DamageTimeInSeconds;
... };
Explanation / Answer
#include "GameFramework/Actor.h" #include "LightSwitchBoth.generated.h" /** * */ UCLASS() class [PROJECTNAME]_API ALightSwitchBoth : public AActor { GENERATED_BODY() public: /** point light component */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Switch Components") class UPointLightComponent* PointLight1; /** sphere component */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Switch Components") class USphereComponent* Sphere1; ALightSwitchBoth(); /** 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); /** Toggles the light component's visibility*/ UFUNCTION() void ToggleLight(); /** the desired intensity for the light */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Switch Variables") float DesiredIntensity; };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.