Hey all!
I have the concept of a frame in my Visual Novel engine. Each frame holds the state of the novel at that time. So if I change say, the narration text, I duplicate the existing frame and then change the narration text property on the duplicated frame.
I’m making use of DuplicateObject() to achieve this and for the most part it works fine. I can assign different text to use as “narration” text on different frames, but when I set the scenePos enum on my 4th frame, it also sets it for every other frame previous to it. Can someone explain what is happening here? Have I made a bad assumption about UObjects being created by DuplicateObject() being completely independent from each other?
Let me know if any other source or information is required.
VNFrame.h
#pragma once
#include "Object.h"
#include "VNCharacter.h"
#include "VNFrame.generated.h"
UCLASS( BlueprintType )
class PROJECT_DREAMCATCHER_API UVNFrame : public UObject
{
GENERATED_BODY()
public:
UVNFrame();
// Get a reference to a specific character by alias
UVNCharacter* getCharacterByAlias( FString alias );
// Text to show on screen (Dialogue/narration/etc)
UPROPERTY( BlueprintReadOnly )
FText displayText;
// Person speaking the text on screen
UPROPERTY( BlueprintReadOnly )
FText characterSpeakingName;
// Background image
UPROPERTY( BlueprintReadOnly )
UTexture2D* background;
// Music track to play in the background
UPROPERTY( BlueprintReadOnly )
USoundCue* music;
// Array of every character defined in the characters file.
// It's possible that only a subset will be used in a scene
UPROPERTY( BlueprintReadOnly )
TArray< UVNCharacter* > characters;
};
VNCharacter.h
#pragma once
#include "Object.h"
#include "VNCharacter.generated.h"
// Enum for the characters position in the scene
// Left, Mid & Right are set in Blueprint with offsets handling
// multiple characters
UENUM( BlueprintType )
enum class EScenePosition : uint8
{
SCENE_LEFT UMETA( DisplayName = "Left" ),
SCENE_MID UMETA( DisplayName = "Mid" ),
SCENE_RIGHT UMETA( DisplayName = "Right" ),
NOT_IN_SCENE UMETA( DisplayName = "Not in scene" )
};
/**
*
*/
UCLASS( BlueprintType )
class PROJECT_DREAMCATCHER_API UVNCharacter : public UObject
{
GENERATED_BODY()
public:
// Default constructor
UVNCharacter();
// Character alias. The internal code will look for this character by alias
UPROPERTY( BlueprintReadOnly )
FString alias;
// What is the current emotion displayed on the screen
UPROPERTY( BlueprintReadOnly )
UTexture2D* currentEmotion;
// What is this characters position in the scene?
UPROPERTY( BlueprintReadOnly )
EScenePosition scenePos;
// Add an emotion to the characters available emotions
void addEmotion( FString& emotionName, FString& pathToEmotion2DTex );
// Set the current emotion of the character from one of the available emotions
void setEmotion( FString& emotionName );
private:
// All available emotions for this character
TMap< FString, UTexture2D*> emotionMap;
};