Select an actor with mouse click and call actor's class function with UMG button c++
I'm trying to select an actor with mouse click and use UMG buttons to for example change material on selected actor. Can someone please guide the right way to implement this in C++ like how to get/save the reference of selected/last clicked actor? Buttons are different materials and I have SetMaterial implemented in cube and sphere classes which takes a material parameter sent by pressed UMG button. Or should it be done some other way?
asked May 08 '18 at 12:15 AM in C++ Programming
Hi, the first thing you need is to get a reference to your actor. In player controller on mouse click call function
answered May 08 '18 at 03:41 PM
1.mouse click ,you can get screen position. 2.use "PlayerController->DeprojectScreenPositionToWorld" can get startposition ,direction,and compute endposition . 3.you can use UKismetSystemLibrary::LineTraceSingle() get actor. 4.UMG Botton call (step.3 get actor) function ,and change material.
answered May 09 '18 at 02:06 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here