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"

Dynamically Create Objects and add to Array from a C++ class via Blueprint

My goal here is to have a C++ class (actor based) that has an array of some UObject that is initially empty. But when I make a BP having my C++ class as the parent I want to be able to say in the BP I want 5 of these UObjects and then bam have 5 and the array now also has 5 and I can move these 5 UObjects around in the BP actor to position them as I please. Hope that makes sense.

Now what I had in mind to do this was have a Count var lets say UObjectCount that when I increment it (or decrement but not my concern right now) it will realize oh hey this variable changed lets make some objects and add them to your array of that holds said objects.

Now here is what I've done so far and it doesn't work. All my logs execute ( a little oddly but still they execute) correctly with no nulls or error or crashing but I don't see my objects I'm making in my BP actor. What am I doing wrong and is this possible? I'm trying to do things procedural and I wan't to avoid doing this all in BP. I need the BP to set some positions up but want the refs to all be in C++.

My attempt. CPP https://pastebin.com/YUqPTAjH H https://pastebin.com/qnUgS2XV EDIT: Current logs print something to this effect

LogTemp: Warning: Updated DoorWays 6 LogTemp: Warning: Added Doorway 6 LogTemp: Warning: Updated DoorWays 6 LogTemp: Warning: Added Doorway 6 LogTemp: Warning: Updated DoorWays 6 LogTemp: Warning: Added Doorway 6 LogTemp: Warning: Updated DoorWays 6 LogTemp: Warning: Added Doorway 6

Seems to fire the same thing multiple times, I think its doing it once since if it really did add to the array that many times it wouldn't be on 6.

EDIT:

So after registering my component I get this for my log now

LogTemp: Warning: Updated DoorWays 6

LogTemp: Warning: Added Doorway 4

LogTemp: Warning: Added Doorway 5

Which is a lot more accurate and better but still not showing in the BP Editor, however it is showing in the WorldOutliner for an existing Actor in the world but that doesn't help me as I can't position and edit like I want to.

Latest code https://hastebin.com/kopifaguca.cpp

https://gyazo.com/f8558974c68cf66209de07afd87ce299

Product Version: UE 4.18
Tags:
more ▼

asked Dec 07 '17 at 11:14 PM in C++ Programming

avatar image

Nonlin
119 8 17 20

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

1 answer: sort voted first

First thing, I see a lot of nested if statements. Try putting else statements on their ends and print to the log.

And always post your logs, even if you don't see a point.

more ▼

answered Dec 08 '17 at 12:11 AM

avatar image

Jin_VE
4.4k 32 77 42

(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