Get array index of a clicked object
Hi everybody, I'm making a simple project where you click on the cube, get the widget with three buttons with which you can change the color of the cube. I've set up everything and it's working fine with one cube, but once I add more cubes it doesn't matter which cube I've clicked on, the color will always be changing on the first one(or if I change the index value manually in the blueprint).
I figured out that the problem is in the Widget Blueprint where I reference the Cube
The circled value is the index of the Cube that will get it's color changed. My question is how can I get the index of the clicked cube so that I can put it into variable that will automatically assign that index to the Cube reference in the Widget Blueprint where I'm changing the color of the selected Cube?
asked May 08 '19 at 12:16 PM in Blueprint Scripting
Just use the node "get hit result under cursor by channel" (needs a controller reference), break the hit result, cast it to BP_Cube, save the output as a variable. Pass the variable to your widget and you're done. If you need help with understanding casting, references or communicating with widgets you can check out these videos I created that will help you get a foundation for the things I mentioned. Specifically video #1 and #25 will be particularly helpful here.
answered May 08 '19 at 02:30 PM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here