Considering switching to Unreal from unity need adivse :)

I am looking at changing from Unity 4 to Unreal Engine 4, and have a concern. Alota the stuff I am working on in Unity I would like to be as painless as possible to port over, and looking threw docs and reffrences I am not seeing anything like this so figure I would ask if its possible and how to do it.
In Unity, I have a C# script set that handels all the Inventorys/Items/Etc,
part of the code or the Items Database side at least, works simple, there is a Class that holds a bunch of items from a item class,
when the player gets a item, they have a local inventory system that refrences the item number to the database, ya da da da
However the problem on the unity side was if you loaded the items database on this scene, then loaded a new scene the database was lost and would need to be recreated all the time, but using a DontDestroyOnLoad(this); it would keep that script loaded and running between loading of diffrent areas.
Is this possible to replicate on Unreal engine?
Where I can for example at the main screne/main menu, create the database, populate its info, then some how keep that object/actor loaded between areas, so then the player starts a new game or loads a old game, the database already is there and ready to go and can also use it on the inventory itself, so the players stuff follows them from place to place without needing to write the data, load the level/area, reload all the other data, then repopulate everything over and over again.
Not sure how better to work it other then refrencing to unitys dontdestroyonload() :frowning:
In a sence On my projects there I have a empty object, that i attach all my scripts to that I want to keep loaded all the time, and prevent that object from being deleted, so my time of day, weather, inventory, skill systems, etc, are always the same

Some sample code of how it works on the Unity side



//items.cs
using UnityEngine;
using System.Collections;

/*
Stores Items themselfs for part of the database
*/
[System.Serializable]
public class items
{
	public string itemName;
	public int itemID;
	public int itemStatus;
	public float fuelValue;
	public float weigth;
	public bool stackable;
	public int stackSize;
	public int itemCount;
	public string itemDesc;
	public float atkPwr;
	public float defPwr;
	public float baseAtkPwr;
	public float baseDefPwr;
	public bool isQuest;
	public float harvestSpeed;
	public Texture itemIcon;
	
	public ItemType itemType;
	
	public enum ItemType
	{
		Weapon, Quest, Food, Consumable, tool
	}
	
	public items()
	{
	
	}
	
	public items(string Name, int ID, int itemS, float fuel, float weig, bool stack, int sSize, string Desc, float aPwr, float dPwr, float bAtkPwr, float bDefPwr, bool Quest, float Speed, string Icon)
	{
		itemName = Name;
		itemID = ID;
		itemStatus = itemS;
		fuelValue = fuel;
		weigth = weig;
		stackable = stack;
		stackSize = sSize;
		itemDesc = Desc;
		atkPwr = aPwr;
		defPwr = dPwr;
		baseAtkPwr = bAtkPwr;
		baseDefPwr = bDefPwr;
		isQuest = Quest;
		harvestSpeed = Speed;
	//	itemIcon = Icon;
	}




//itemsdatabase.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class itemDatabase : MonoBehaviour
{
	public List<items> Items = new List<items> ();

	public void Start()
	{
		Items.Add (new items("Birch Log", 0, 1, 4f, 20f, true, 16, "Birch log, heavy, unrefined", 0f, 0f, 0f, 0f, false, 0f, "birch_log.png"));
	
	}
}




//inventory.cs attached to object that carry inventory, players, chests, etc
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class inventory : MonoBehaviour
{
	public List<items> inven = new List<items>();
	private itemDatabase database;
	public float curWeight;
	
	void Start()
	{
		database = GameObject.FindGameObjectWithTag ("ItemDatabase").GetComponent<itemDatabase>();
		curWeight = 0f;

	}
	
	public void AddItem(int id)
	{
		if(database.Items[id].stackable)
		{
			for(int i = 0; i < inven.Count; i++)
			{
				if(inven*.itemID == id)
				{
					if(inven*.itemCount < database.Items[id].stackSize)
					{
						inven*.itemCount++;
						curWeight += database.Items[id].weigth;
						return;
						
					}
					else
					{
						inven.Add(database.Items[id]);
						curWeight += database.Items[id].weigth;
						inven[inven.Count - 1].itemCount++;
						return;
					}
				}
			}
		}
		inven.Add(database.Items[id]);
		inven[inven.Count - 1].itemCount++;
		curWeight += database.Items[id].weigth;
	}
	
}


Then on the main object that will hold all the scripts to leave alone and not delete I have a DontDestroyOnLoad(this); added to its Awake() function

This might not answer your question specifically but heres a few links that might be helpful as a former unity developer myself.

https://wiki.unrealengine.com/Transitioning_from_Unity_to_UE4

https://wiki.unrealengine.com/Unity3D_Developer's_Guide_to_Unreal_Engine_4

https://wiki.unrealengine.com/HUD:_Unity_3D_OnGUI_Remake

Plus someone is working on a plugin to allow you to code in C#

Also this How can I pass data from one level to the next? - Programming & Scripting - Unreal Engine Forums

Fasinating, so if I am reading that right, and please correct me if wrong :slight_smile:
But it seems that the way unity works, from experience, is on loading a scene, it loads the stuff related to that scene, destroys everything from the last scene

But with Unreal, I can tell it to use a GameMode, set things in that and each level loaded would have the same default GameMode so all the data is still present as long as I keep that aspect or mode in the new level/area. So things like a inventory database would not reload itself each time, but simply in a sence merge over to the new level loaded keeping its data, settings, etc
So if that is the case, while would need to re-think how all my old code works together, i would end up with one area with everything in a GameMode that in a sence is like a GameObject in Unity with a DoNotDestroyOnLoad added to it
Am I correct?

You could create a persistent level and all the other levels be levels within the persistent level and you can stream in / out the levels you need and don’t. When you put all your inventory code into the persistant level? Bam. It’s always there. Or you could use Blueprints to bind all the values to the MainCharacter, which you can save when you choose.

Humm I thought the persistent level was only in the editor from how it was worded on the docs I didnt think it was in the player/standalone as well o_o
That is wicked lol Wow to think all the time i spent in unity and all that money could have been over here doing much better more awsome stuff… ya i think i am going to have to just up and move to unreal engine, way to much to gain.

Yeah, you can use the Levels system to do so many cool things. You could even code and RPG where the Player and the data are stored in Persistent Level, The Game’s world could be Level1 (Child of Persistant Level) and then a Battle scene as another child of Persistant level and with a little help from Blueprints they will all work together famously; You could have all three loaded at once if you wanted or just one at any time; The world is your oyster.

If at any point you need help with the Levels system, drop me an email: contact@kitatusstudios.co.uk and I’ll try my best to get back to you ASAP with an example of what you want to show how easy it is.

Looking at all your code as well, I think it can all be done 100% in Blueprints. What does this mean? It means you could do everything you did in Unity without typing a single line of Code!

Welcome to Unreal Engine! :slight_smile: