Download

[Feature Request] Create any C++ Object in blueprints

I’ve been using UE 4 since it arrived and would like to create an RPG API for other dev teams to use. I’ve got lots of working systems and ideas that any team could very easily utilise with little effort. What I want to achieve is a blueprint based Drag’N’Drop system using only blueprints to create every aspect of an RPG.

Firstly I would need to be able to create any c++ object, that doesn’t get ‘Spawned’ into the world or have to extend UObject, within a blueprint. This means I could have a class like:



class MyClass {

public:
	MyClass ()
	{
		//Do stuff
	}

	int someInt = 0;

	void doSomething()
	{

	}
}


And create it as a blueprint to be assigned as a property to another class. E.g.



Class MyOtherClass {

     MyClass* myClass;

}


And in blueprints create a new instance of each object , and set myClass to the value of the newly created MyClass, all within the blueprint.

The reason for this is so I can make it possible to create a linked Conversation and Combo system for other, non-programmers, to be able to create their own conversations without having to do it in code or in an excel spread sheet and load the data when the game starts.

I’ll will upload some examples of what this might look like.

If this is already possible then please tell me.

All objects that would be exposed to blueprints in any fashion must extend from UObject and use the requisite UProperty macros to expose properties to it. Stock C++ does not have a reflection system, so it’s impossible to just expose any arbitrary C++ object to Blueprints.

You could use a combination of UStructs for data only objects, and extend anything else from UObject. Direct instantiation of UObjects is not exposed to Blueprints, however it’s trivial to introduce a new global Blueprint accessible ufunction that can create these specialized UObjects you’re designing, and return them for any Blueprint purpose. This was the approach I used for UMG because Actors are too heavy weight, but needed a UObject wrapper for the underlying Slate widgets, which are normal C++ classes.

Depending on what these RPG Apis consist of, you’ll need a combination of those things + likely things that extend from UActorComponent that can be placed on a blueprint just like a UStatciMeshComponent. For anything that’s interactive you’ll likely want to make them components. For example, you could make a reusable component for soemthing thats “Lootable” and just attach the Lootable component to any other blueprint to allow the player to Collect something when they click on it.

In that case, at the very least is it possible to create ‘UObjects’ that don’t have to be spawned?

And thanks for the ideas and help there.

Just to give you a better idea of what I’m trying to use blueprints for, here’s an example.

My conversation system uses a class I made called a Message:



class Message
{

public:
	Message(FString tempNPCReplyMessage, FString tempPlayerRelpyMessage)
	{
		npcReplyMessage = tempNPCReplyMessage;
		playerRelpyMessage = tempPlayerRelpyMessage;
	}

	FString npcReplyMessage;
	FString playerRelpyMessage;
	bool npcReplied = false;
	Quest* questGiven;

	TArray<Message*> PlayerReplies;

	/*
		Adds a Message to the PlayerReplies rather than doing 
		Message->PlayerReplies.Add();
	*/
	void Add(Message* MessageToAdd)
	{
		PlayerReplies.Add(MessageToAdd);
	}

	/*
	Adds an array of Message(s) to the PlayerReplies rather than doing
	Message->PlayerReplies.Add();
	*/
	void Add(TArray<Message*> MessagesToAdd)
	{
		for (int i = 0; i < MessagesToAdd.Num(); i++)
		{
			PlayerReplies.Add(MessagesToAdd*);
		}
	}		

	/*
		Checks if this is the end of a conversation, 
		i.e the player has no more possible choices
	*/
	bool IsEnd()
	{
		return PlayerReplies.Num() <= 0;
	}
};


As you can see a message has a collection of other messages. This is to make it so each message can have an infinite amount of other linked messages. if you’ve played any game that uses a conversation ‘Wheel’ then this is exactly what I’m trying to create.

The player interacts with an NPC and is given both a response and then a list of possible choices, i.e. questions/responses regarding the NPCs message. Each time you press a button the relating Messages’ ‘npcReplyMessage’ is displayed followed by the list of ‘playerRelpyMessage’ for each linked message. If you pressed 1, then the Message at index 0 would be chosen etc.

My aim is to be able to create a full conversation system that allows my team to create any amount of messages in blueprints so they can easy visualise how the conversation will play out.

Hi Belven,
I don’t think it is exactly what you are looking for, however I did create a tutorial for an NPC dialogue system created entirely in blueprints, perhaps you can use some of it to help with your teams NPC conversations:

That’s cool, The system I’m using right now works, well mostly, but the selector you’ve created is exactly what I’m looking for :smiley:

I’ll see how you use it in your guide and gather more info on how I can mix c++ with bluprints.

I want to avoid using blueprints to perform functions as much as possible. I want the C++ to control what happens and the blueprints to define variables on classes. The team I’m working with are mostly completely new to UE4, Blueprints and anything to do with software like this. The less they have to do the better :smiley:

Just as a heads up, as well, I have currently got:

  • A fully working combo based combat system, that both bots and players use.
  • A mostly working conversation system, just a few bits of logic to work out
  • The ability for the player and bots to dodge and block
  • The player can lock on to targets
  • Allies and enemy NPCs
  • The basics of an Inventory System
  • Pretty good AI for the bots, they know when to dodge attacks etcs
  • Pathing for NPCs, setting patrol routes etc
  • An effects system to apply buffs, debuffs and damage/healing to bots in the game

Currently I could make a fully working game but I have nothing but code and a few models :slight_smile: