Proper data structure to use?

Hey guys so I’m making a car game and I am stuck right now. Basically in my game, the player can purchase cars throughout the game, and choose to race with it in a particular level. Unfortunately I am quite stuck here.

Basically in my game instance, I have a variable called “OwnedCars.” This variable is a blueprint map. It’s key is of type EVehicleModel (this is an enum I made that has every single car in the game represented as an enum). It’s value is of type “VehicleSaveProperties” which is a struct. In this struct, I store a variable called “Car instance” (which is the class that all cars in my game derive from) and a boolean called “IsOwned” (which checks if I can use this car in game or not. This boolean is set to true if it was purchased).

My problem is that in my game instance, I can make the blueprint map alright, but I cannot assign a “Car instance.” I am very stuck here so what should I do. I need to be able to store a blueprint class of that car so I can spawn it later in game.

Hi there,

If I understand correctly, you want to store a reference to the actual class itself, correct?
In that case, when you select the type of the variable for “Car Instance”, choose “Class Reference” instead of “Object Reference”. Then you will be able to assign it with any child class of that class.

Then you will be able to pass that into a spawn call like this:

By the way, I would recommend you name the variable something like “Car Class”, since “instance” has a special meaning, and it might be confusing.