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. 

Assigning property to created component mesh

I am trying to create an array of clickable boxes that will be a base for let's call it chessboard. I've managed to create an array of objects like shown in pic alt text and the blueprint itself alt text. What i did later was to create a function that would print the name of the component of "board" blueprint that was hit by left mouse button. I've reached this alt text, which does not satissfy me as i need to use the name or the index of component later to be able to f.example change material of one particular component. So my question is what can i do to be able to assign a value as a property of each box to know which of them is number 1 and which is 400 and so on and so on, and it would be lovely if the number would correspond to the sequence the boxes were created. PS the yellowish color was assigned during creation of static mesh for all boxes created under loop index from 161-220, and i would love to save this index in some kind of an array or any other kind of variables/tags etc. to be able to use it later. (I still mean the way that i the index is assigned to component, so if i say component with index 180 changes its material to blue for exmaple.) PS' Plz help

Product Version: UE 4.17
Tags:
componentp.png (691.1 kB)
componentp1.png (1.3 MB)
componentp2.png (127.0 kB)
more ▼

asked Oct 22 '17 at 04:46 PM in Blueprint Scripting

avatar image

Fanish
6 1 2 4

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

1 answer: sort voted first

The way I would solve this is the following:

First, create a new blueprint called Box (or something similar) and populate it with all the variables that you want - index, color, additional components, whatever.

Second, create another blueprint called BoxCoordinator, which would control the spawning, destroying and general bulk actions on Boxes. Additionally it would also hold the index for all Boxes (array of Box references), just for convenience.

Next, to make it more interesting, you could make an interface that would hold all the most used functions for accessing and changing variables from the BoxCoordinator on the Boxes itself.

Examples of such functions would be:

A function that changes the color of a Box with a specific index.

A function that gets all the Boxes that are in a specific color.

A function that gets all the Boxes in the n-th row.

A function that spawns a new Box row.

A function that destroys the n-th column and fills up the empty space with boxes from the n+1-th+ columns

Etc. you get the point.

Furthermore, as the next step, It would also be nice if you properly split the logic between the Box and the BoxCoordinator. What I mean by this is to have all the Box-related functions on the Box blueprint and to have all the functions that perform bulk actions on the BoxCoordinator. For example, you would have a function named ChangeColor on the Box blueprint and ChangeRowColor on the BoxCoordinator blueprint that would iteratively call ChangeColor on all the boxes of the n-th row.

I hope this helps.

more ▼

answered Oct 22 '17 at 06:28 PM

avatar image

neelix32
154 2 3 7

avatar image Fanish Oct 23 '17 at 05:13 PM

Your tip was very helpful but i found another problem with setting a variable of child actor component, which was the fact that it cant inherit the index. I guess i did something wrong but i found another solution for the problem. I simply needed to int->string and then string->name and now i can set tag of a component as the index of creation so it absolutely solved the problem.alt text I also tried to do it other way but i faced problems with casting i dont understand well yet and i could not find any function that would allow me to connect the reurn value to set(index) of childactor(component). Once I managed to plug sth to the target node but i got an information that cast would always fail beacause the box(actor that is in my board BP) cannot inherit from the board so i guess i will keep going with the solution i found but i hope you can give me some tip how to do the casting properly. PS Thank you very much for helping me to find a solution. alt text

screenshot-89.png (162.4 kB)
screenshot-88.png (116.1 kB)
(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