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. 

Array of custom class objects

To get more into the engine I wanted to make a simple tetris game after completing the c++ programming tutorial series.

I have my own fieldpoint objects that contain a staticmeshcomponent and some ints/bools for game information.

Now I wanted to make my field as an array of these objects but I can't manage to find the correct way to instantiate them in the constructor of my field class. When I use World->SpawnActor a fieldpoint object is spawned but I have no reference to it, so I can't use it in the field class anymore. With CreateDefaultSubobject I can't get it working at all. These are the methods I got to know from the c++ programming tutorial series.

Any idea for a solution for this? Thx already.

Product Version: Not Selected
Tags:
more ▼

asked Mar 06 '15 at 02:48 PM in C++ Programming

avatar image

DJjojo
5 1 3 4

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

1 answer: sort voted first

Use BeginPlay() instead of constructor (spawning won't work in there, you should not put anything other then setting default) and World->SpawnActor returns spawned actor refrence, returns null if spawn failed, use it to assign objects to varables or array.

more ▼

answered Mar 06 '15 at 02:56 PM

avatar image

Shadowriver
36.6k 930 169 1111

avatar image DJjojo Mar 06 '15 at 03:00 PM

I guess the part that I put it in the constructor was the main failure here. I did know that SpawnActor returns a reference but I couldn't access it in other functions when used in the constructor. Thx a lot, going to try this.

(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