Download

Using Blueprints to store Data

Hey all,

So I have recently encountered an issue; I am trying to build an Animation System which can branch out based on previous input; essentially its a Binary Tree (So basically a combo system eg Square, Square, Triangle)

I tried doing this via USTRUCT but I can’t store pointers to other USTRUCTS

AnimationFrame.h



#pragma once

class UAnimationAsset;



#include "AnimationFrame.generated.h"

UCLASS(BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent))
class FANTASYGAME_API UAnimationFrame : public UObject
{
    GENERATED_BODY()
    
public:

	// Sets default values for this character's properties
	UAnimationFrame();

	UPROPERTY(Category = "Frame Data", EditDefaultsOnly, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
	UAnimationFrame* CurrentAnimation = nullptr;

	UPROPERTY(Category = "Frame Data", EditDefaultsOnly, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
	UAnimationFrame*  SquarePressed;

	//Triggers after longhold conditions are achieved.
	UPROPERTY(Category = "Frame Data", EditDefaultsOnly, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
	UAnimationFrame* TrianglePressed = nullptr;

	FORCEINLINE UAnimationFrame* GetSquarePressed();

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Long Hold")
	float LongHoldTriangle = 1.f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Long Hold")
	float LongHoldSquare = 1.f;

	//Triggers after longhold conditions are achieved - also does the initial square animation
	UPROPERTY(Category = "Frame Data", EditAnywhere, meta = (AllowPrivateAccess = "true"))
	UAnimationFrame* LongSquarePressed = nullptr;

	//Triggers after longhold conditions are achieved - also does the initial triangle animation
	UPROPERTY(Category = "Frame Data", EditAnywhere, meta = (AllowPrivateAccess = "true"))
	UAnimationFrame* LongTrianglePressed = nullptr;   
};


I can create the initial blueprint with parent class “AnimationFrame” - but when editing the BP in the property inspector when I want to assign the next animation frame, I can’t reference it or find it in the finder at all.

Previously I had it working when I used TSubclassOf<UAnimationFrame> SquarePressed; however I have to instantiate it per new attack frame but also the generated object from NewObject<UAnimationFrame>(SquarePressed); contained empty pointers when I had set it in the Blueprint.

Attached is an imgur album for some better explanations http://imgur.com/a/moSfu

What would be the best way to go about this? Am I on the right track? I have it mostly all working bar storing persistent data.