x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

Product Version: UE 4.19
Tags:
more ▼

asked Mar 21 '18 at 03:22 AM in Blueprint Scripting

avatar image

nerdares
6 1 4 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

alt text

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

alt text

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.

untitled-2.png (52.0 kB)
capture.jpg (48.9 kB)
more ▼

answered Mar 21 '18 at 05:15 AM

avatar image

MajorMcDoom
13 1 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question