I’m really new to UE4, and I just wanted to know if anyone has a script or C++ code that allows the user to click one of the several movable actors(or characters), which the user can then can drag with the mouse or use the arrow keys to place it at another location.
(So to summarize, you click a square, either drag it or press buttons to move. And then I just need to do it with a bunch of them.) (Should be pretty simple right?)
See default c++ templates: topdown and puzzle. In first one you can find how get hit location under mouse cursor, in second - how click and select actor.
Actors have on click event, just make them register themselves as selected by setting “Selected” varable in somewhere global (player controller is best place in this case ). I actully have a tutorial (but for somethign else) showing OnClick in action:
Multi select would be harder, definitely you will need to keep selected actors in array insted single pointer, as for making RTS-style select box, you would need to do some tracing (maybe Box tracing from camera?) and HUD work (i actully thin AHUD class would make it a lot easier then UMG, sincei n HUD canvas it's a lot easier to draw boxes and lines on screen)
As far as I know there is no ready solution. You need implement some array that manages currently selected actors: add to array on click-on-actor, remove from array on click-on-already-added-actor. And then you just need to somehow set location for actors in that array by mouse clicking on non-actor-space.
You can migrate topdown controller to your project and then do what you want. I’m currently off the editor, somewhere is such option. Try right-click on topdowncontroller in content browser
Thanks, but I think I’m just too new to this. Give me Blender and I’m fine, but I just haven’t watched any videos for this. I’ll definitely watch yours, though.
I guess I could use it like that! Thanks!
I guess the only thing I need to know is, what object do I put the blueprint on? The movable character or the block? Also, when I search for the names of the nodes he has, they don’t come up.