Hello,
does anyone have an idea of why and HOW to do so that when the values of the sliders are changed, it changes the values of all the lights and not only of the first placed one?
Hey there @someonelsee1! So you’ve got lots of options really. You could make an array of these actors and then run a foreach over them to change the color. Or you could get them every time you call that command for less efficiency a little like you already have it set up:
Hope this helps!
Thank you @SupportiveEntity !
What would be the more efficient way to change the values of each lamp when I click on one of them ?
I suppose it requires Arrays but I don’t know how to proceed…
This panel would appear and be active only when you click on one lamp in the scene
Why do it in the level blueprint and not in the widget blueprint ?
You can do it in any blueprint. You could do it in a widget - but that could get awkward for reasons too numerous to list. I did it in the LB to demo it.
This functionality belongs in the player controller, maybe in the pawn. Depends on the setup. Think of the PC as of the will of the user - this is where the actor selection would naturally occur. You can see the Get Hit Results Under...
node works directly with the PC.
I think I’m starting to understand. But anyway it doesn’t work hihi… I’m stuck on this for so long, the fact of choosing only one actor to modify. Unreal still has (too much) hidden spots for me.
As I’m a blueprint beginner, part of my code must not be “clean”, so it could complicates things when I try to replicate solutions
The script is up there. If you do not post your setup, no one can help you.
I have 2 different UMG here.
The first is my “Edit panel” to drag and drop actors in the world, and modify them.
The latter is implemented in my main UI which is constantly displayed, and it opens when I click on the Edit button.
In the first one, the “Parameters panel” for the lights opens when I click on the Lights button.
Here’s my code for the parameters of the Cube Lamp, one of the two lamps implemented.
Focus on fixing one thing at a time. See if you can use the Player Controller to select actors in the scene. Once you have that working, work on sending those objects data from the widget.
You’re using Get All Actor of Class - this will not work if you want to change the selected actors only. How / where did you implement the script I posted?
As a rule of thumb - avoid scripting too much in the widget, widgets are supposed to show stuff, not drive logic.
I see you have a lot of stuff going in the right direction - like the dynamic material; ensure you can select 1 actors only and you’ll be 1 step closer.
Although the way you handle it looks like a memory leak waiting to happen - you keep recreating new materials. It’s the actor that should create and hold a reference to its own material - so things are logical and compartmentalised.
The widget should not care what materials the target actor is working with. The widget sends raw data to the actor, it’s processed there (if at all needed) and then pushed into the dynamic material.
I know, for the purpose of testing your script I removed this part.
I implemented the script in the level blueprint as you shown:
Okay, could you show me how?
Here’s a project with this (albeit simplified) mechanics:
- game mode
- player controller
- dynamic material
- bunch of actors
Clicking an actor and dragging a slider changes the material param in that actor.
I see that you tried to use it here:
You have the right actor reference but still rely on Get All Actors? Why?
Okay, and what should be in the widget to remplace what I currently have ?
This should not be in the widget at all:
- widget dispatches color picker data
- the player controller catches it and sends it to the selected actor
- the actor creates and stores the material reference
If I delete the All Actor, where do I say that I want the intensity of the lights to be modified ?
If you want to modify a single selected light - the actor you selected is right here:
Ideally, you’d have a Custom Event in the actor that changes the intensity of its own light. Do as little in the widget as possible. None of the above belongs in the widget, see post above.
At some point you will also need to look into how interface communication
works to avoid casting.