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. 

How to add/access classes to/from an array?

I can't seem to figure out why this doesn't work on my own. I'm inserting a specific class into an array of classes at a specific location in the array. Then later trying to access that same location to get the class I stored there earlier, but it comes up empty.

If I try to do the same thing with an array of integers it seems to function in the way I want it to.

alt text

Product Version: Not Selected
intoarray.jpg (96.4 kB)
more ▼

asked May 18 '14 at 11:23 PM in Blueprint Scripting

avatar image

298 21 16 43

avatar image DamirH May 18 '14 at 11:28 PM

I may be wrong, but the reason it works with integers and not classes may be due to the fact that integers get passed by value, as literals, while classes are most likely passed by reference, so you need an object reference that is kept in your array. This is just from the top of my head so I might be mistaken.

avatar image Shadowriver May 18 '14 at 11:43 PM

You correct, thing is UE4 object management system registers classes by making UClass objects which behaves like normal objects, this allows to contain reference classes in variables or arrays not only in blueprint, but also in C++ which is normally impossible. So he trying to do is contain UClass staic object references in array which should work.

avatar image Bohrium May 19 '14 at 09:10 PM

I roughly understand how arrays work. I roughly understand how storing actors/classes in variables works. But nothing I want to put into an actor/class array seems to actually get stored in one for some reason.

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

2 answers: sort voted first

My problem was that I was't able to put anything into the array or get anything out of the array and I guess I resolved it somehow. I don't know what exactly happened. Using the exact same setup it wasn't working. Then I decided to add a tooltip for the class array and it suddenly started working. Removed the tooltip and it was still working. Tried replicating the problem by making a new class array, but now it just seems to work by default.

So while it's working now, I have no idea what caused it or what I really did to fix it.

more ▼

answered May 20 '14 at 11:07 AM

avatar image

298 21 16 43

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

From my experience, putting ANY kind of class input into a SpawnActor node ends in disaster, even if it initially works fine. It corrupts the return value even if the input is exactly the same. Maybe that is my only problem, but it could affect you as well.

Put print strings on both sides of the Spawn Actor node, to see that the input is what you expect and then confirm that the return value is also correct. Maybe put one in front of your Add Array too so you know what is going in is good.

If that all works, try using the return value on the spawn actor and plug it into something like the Target of a Set Material node. One of my main problems was this conversion working fine WITHOUT Class input(Manual class set on Spawn Actor), and then corrupting on project reload WITH Class input.

Your issue might be different, but if it is the same there may be some bigger problem that the devs need to investigate.

more ▼

answered May 20 '14 at 09:09 AM

avatar image

1.8k 131 68 110

(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