How to click and select different actors

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)

I think I’m getting more confused the more I try. :stuck_out_tongue: :smiley:

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.

Checkout some documentation, maybe it helps(C++ Programming Tutorials, Gameplay Concept Examples)

Try default editor template projects in blueprint mode, maybe that way it would be easier to find some solution.

I think my biggest question is why certain nodes aren’t able to be copy and pasted in. My guess is that they have to be defined somewhere else…

I don’t understand which nodes exactly you mean. Nodes in BP or nodes(some code pieces) in c++?

Blueprint mode. Hmm. I’ve taking a C++ class… Maybe I’ll try it over there…

For example this node won’t paste into another project.

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

Right-click on blueprint class and there it is

77531-migrate.png

Ahhgg… I think I’m just too new to UE4… Maybe you guys could figure it out? I’ll go and watch some videos I guess…

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.

If you’re trying to pick up and drag objects along with you, like with the Gravity Gun in Half Life 2, check out this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums

:open_mouth: 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.