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"

Creating array of Point Light Components within a BluePrint (and possible bug)

I have a base blueprint which will be used to create several others that will all share some specific functionality. One such function is that a number of lights will light up depending on a changing integer value on each instance of the object. Each instance will have a different number of lights, so I can't just hard code it.

My attempt to do this was to use an array of Point Light Component References. However, you can't set the default entries on such an array with existing PLCs in the current BP scene, which seems odd. I tackled this by having the construction event add each light one at a time to the array, which is obviously a fudgy solution.

PLC Lights in the BP scene and not showing in array add interface

alt text alt text

The workaround

Manual population of array at runtime

I have two things, one question and one possible bug:

Q: How can I have a predefined array on a BP that I can set each element to an existing Point Light Component in the BP scene - OR - a way to achieve the same goal in an automated/expandable way (not manually add them).

BUG: When I run my game in the editor, I'm seeing a random number of either "Nothing" entries getting added to the PLC array, or sometimes items called "TRASH...(I can't make it do it right now and can't remember the rest of the line)". I can remove them at runtime to prevent issues, or clear them between runs with the "Trash" icon on the array, but they'll come back when I stop and run again (but not always, often depends if I edit the blueprints or some such).

Array when its behaving

The array when its behaving

Array when random "None" entries show up

The

Product Version: UE 4.9
Tags:
more ▼

asked Jan 10 '16 at 09:02 AM in Blueprint Scripting

avatar image

Durandle
16 4 6 5

avatar image vanlacke Jan 10 '16 at 11:09 AM

Hard to understand for me what you're trying to do exactly.. You just want to add a certain number of point lights to a BP quickly & easily? Is the only issue here adding them manually (and the bug, which I can't comment on)

What is the BP meant to do exactly?

avatar image Durandle Jan 10 '16 at 11:42 AM

I want to create blueprints based on this base blueprint, each of which will have a number of lights, that based on a calculation that results in a %, will either be on or off.

So say the result is 50% and there are four lights in the array, lights 1 and 2 will turn on (based on a foreach loops over the array). If there are 10 lights in the array, 1,2,3,4 and 5 will turn on.

I don't want to make logic for each possible number of lights, nor do I want to manually insert each light in to the array for each instance of the BP (the workaround I did). I want to be able to create a new BP based on the base BP, add a number of lights, set them in the array as default elements in the editor and be done.

I'm happy if there is another way to achieve that result by other equally simple means.

avatar image vanlacke Jan 10 '16 at 12:20 PM

Sounds like you have everything else handled, except for the amount of lights. I'll post an answer on how to add them easily. Also with some simple positioning functionality. Not sure how you wanted it, I assume you have it covered.

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

1 answer: sort voted first

Here's how to add lights dynamically using only a variable + construction script.

alt text

Here it is in action

https://www.youtube.com/watch?v=SW5IfwqK-JA&feature=youtu.be

lights.png (326.2 kB)
more ▼

answered Jan 10 '16 at 12:28 PM

avatar image

vanlacke
1.5k 65 132 103

avatar image Durandle Jan 10 '16 at 05:25 PM

That is pretty nice, I may well use that for something else - though it doesn't actually tackle the issue I have, as the lights are manually placed on the model and may be placed in non-linear positions (perhaps a circle on one, a line or arc on another). I was aware that dynamically creating the lights was a solution, though I hadn't planned to make it as dynamic as your BP allows - I already have a bunch of ideas I could use that for now I've seen it :)

avatar image vanlacke Jan 10 '16 at 06:41 PM

Oh, so the problem is adding them into an array, not into the BP itself. Sorry, should have noticed you specifically said array. Was up super late :)

Would this work for you, then?

alt text

I did the forloop because directly connecting the output was giving me an extra billboard component.

lgihts2.png (87.1 kB)
avatar image Durandle Feb 04 '16 at 07:31 AM

Forgot to come back on here :) Using a loop to achieve the same thing had the same issue. However, the fix was that the target array needed to be cleared first - I assumed it'd be cleared before each "construction" event, but apparently not, at least not properly. I guess that's why some items ended up being called "TRASH" or other random junk.

avatar image Durandle Jan 13 '16 at 10:42 AM

While I get the point of what you've suggested, there's no telling how it may order the children it iterates over, and in the end its using a foreach to effectively do the same thing as my manual code does - I suspect it will fall foul of the same random extra entries issue - but I'll try it all the same (I did thinking of doing this, but assumed it wouldn't help so didn't).

(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