Here is a .h file, modified somewhat while working on the tutorial.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
UCLASS()
class BATTERYCOLLECTOR_API APickup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APickup();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// return the mesh for the pickup
FORCEINLINE class UStaticMeshComponent* GetMesh() const { return PickupMesh; }
// return th value of bIsActive
UFUNCTION(BlueprintPure, Category="Pickup")
bool IsActive();
// set the value of bIsActive
UFUNCTION(BlueprintCallable, Category="Pickup")
void SetActive(bool NewPickupState);
protected:
// true when the pickup can be used
bool bIsActive;
private:
// static mesh to represent the pickup in the level*/
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Pickup", meta=(AllowPrivateAccess= true))
class UStaticMeshComponent * PickupMesh;
};
- UFUNCTION and FORCEINLINE
- These are C macros that expose the function or item to Blueprint scripts.
- A Function declaration manual for unreal
- She covers BlueprintPure and BlueprintCallable in the video
-
UFUNCTION(BlueprintPure, Category="Pickup")
bool IsActive();
UFUNCTION(BlueprintCallable, Category="Pickup")
void SetActive(bool NewPickupState);
- But it seems BluprintPure is an observer, it does not change the object
- And BlueprintCallable is a transformer.
- Category tells the Blueprint where to put it in the node list.
- FORCEINLINE makes an inline function, it seems equivelent to inline.
-
FORCEINLINE class UStaticMeshComponent* GetMesh() const { return PickupMesh; }
- Here both IsActive and SetActive will have blueprint nodes created for them.
- UPROPERTY