Add PaperSpriteComponent to APickup

This commit is contained in:
baz 2024-08-16 02:14:29 +01:00
parent 707728940a
commit ab8f0a2f32
3 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,7 @@
#include "PlayerCharacter.h" #include "PlayerCharacter.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
// Sets default values // Sets default values
APickup::APickup() APickup::APickup()
@ -14,8 +15,13 @@ APickup::APickup()
// Create Sphere Component // Create Sphere Component
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component"));
SphereComponent->SetupAttachment(RootComponent); SetRootComponent(SphereComponent);
SphereComponent->SetSphereRadius(25.0f); SphereComponent->SetSphereRadius(25.0f);
SpriteComponent = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("Sprite Component"));
SpriteComponent->SetRelativeRotation(FRotator(0.0f, 90.0f,-90.0f));
SpriteComponent->SetRelativeScale3D(FVector(.5f, .5f, .5f));
SpriteComponent->SetupAttachment(RootComponent);
} }
// Called when the game starts or when spawned // Called when the game starts or when spawned

View File

@ -5,6 +5,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Components/SphereComponent.h" #include "Components/SphereComponent.h"
#include "GameFramework/Actor.h" #include "GameFramework/Actor.h"
#include "PaperSpriteComponent.h"
#include "Pickup.generated.h" #include "Pickup.generated.h"
UCLASS() UCLASS()
@ -21,7 +22,10 @@ public:
double PickupMovementSpeed = 1000; double PickupMovementSpeed = 1000;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USphereComponent* SphereComponent; USphereComponent* SphereComponent = nullptr;
UPROPERTY(EditAnywhere)
UPaperSpriteComponent* SpriteComponent = nullptr;
public: public:
// Sets default values for this actor's properties // Sets default values for this actor's properties

View File

@ -8,7 +8,7 @@ public class vampires : ModuleRules
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "Paper2D" });
PrivateDependencyModuleNames.AddRange(new string[] { }); PrivateDependencyModuleNames.AddRange(new string[] { });