memo 12  C++ 배터리 콜렉터 03


C++ Battery Collector: Making Your First Pickup Class | 03 | v4.9 Tutorial Series | Unreal Engine




#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
UCLASS()
class TUTORIAL_BATTERYCOLL_API APickup : public AActor
{
       GENERATED_BODY()
       
public:       
       // Sets default values for this actor's properties
       APickup();
protected:
       // Called when the game starts or when spawned
       virtual void BeginPlay() override;
public:       
       // Called every frame
       virtual void Tick(float DeltaTime) override;
       /** Retourn the mesh for the pickup */
       FORCEINLINE class UStaticMeshComponent* GetMehs() const { return PickupMesh; }
private:
       /** Static mehs to represent the puckup in ther level */
       UPROPERTY(VisibleAnyWhere,BlueprintReadOnly,Category="Pickup",meta=(AllowPrivateAccess="true"))
       UStaticMeshComponent * PickupMesh;
};


Generated Header 







UCLASS 매크로









Tick 함수


// Sets default values
APickup::APickup()
{
       // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
       PrimaryActorTick.bCanEverTick = true;











UPROPERTY(VisibleAnyWhere,BlueprintReadOnly,Category="Pickup",meta=(AllowPrivateAccess="true"))
UStaticMeshComponent * PickupMesh;



















FORCEINLINE class UStaticMeshComponent* GetMehs() const { return PickupMesh; }





#include "Components/StaticMeshComponent.h"  ( fixed error line )

#include "Pickup.h"

// Sets default values
APickup::APickup()
{
       // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
       PrimaryActorTick.bCanEverTick = true;
       PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
       RootComponent = PickupMesh;  ( fixed errorline )
}


+ Recent posts