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 modify struct array inside struct? c++

Hi, I tried to post this as a thread in the forums but apparently it didn't get through for some reason.

I'll try to keep it short. I am making a hex tile grid procedural generation. I use Instanced Static Mesh components to generate the tiles given X,Y coordinates and position the transform of every instance. I was previously using actors but because of performance problems im switching to ISM's. Since I cant store any data in the ISM instances themselves I am trying to keep everything indexed using my own Ftile_indexer struct. After I place the tile instance I create a struct of this type and I store it in an array. This works fine with the data sent as initialization on its constructor.

Problem is, I have a second struct array inside Ftile_indexer. It is an array that stores structs of another struct called Fneighbour. I am doing this so I can keep track of the graph that is being generated when I spawn the tiles. Whenever I find out that a tile should be neighbor to another tile I send a Fneighbour struct to the tile and save the information of its neighbor in its neighbors array. For some reason, when I add the neighbor, the array is getting modified (I checked with a debug message) as its size is increasing. Nevertheless, when I try to get the neighbor array from an Ftile_indexer struct the array is empty. Am i losing the references somewhere? I'm not really sure what I'm doing wrong.

This is my header for the map_controller and this is the .cpp. generate_hex_grid() : function where i spawn the tiles through instancing from a random ISM. generate_graph(): is where i am setting the neighbors.

If Anyone can come up with some helpful advice or a different solution for an indexing system that works with tiles and neighbors I would really appreciate it. Thanks in advance. Cheers!

Product Version: UE 4.13
more ▼

asked Oct 12 '16 at 06:30 PM in C++ Programming

avatar image

1 1 4 6

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

0 answers: sort voted first
Be the first one to answer this question
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