Hello Neighbor like magnet gun in ue4?

ive been trying for a few weeks now and cant seem to get it working, but does anyone know why my code isnt working?

ive been trying to make a magnet gun like in the game hello neighbor, but cant seem to figure out how they did it, here is my code currently:

i want the magnet gun item to attract only metal intractable items in the game, but it wont attract anything at all

any help would be appreciated!

Your “move component to” node does not have any object as a focus. Also, the whole setup is unoptimized and is a bad practice of writing scalable and efficient code.

is that all you got to say about this. why not help him out so his code is not bad no more.

@MatthewGod500 Which one are you referring to? Making it scalable? Optimised it? Fixing the bug? Covering every one of them is complex except for this specific bug.

all of it. maybe try helping him out if you know some code.

@MatthewGod500 Sure, I can help with this very specific problem, but I can’t help you in the long run. If you want to improve the way you write your code, there’s no other shortcut but to learn about C++ and its data structures. This includes object-oriented programming in C++, and hopefully, it will make the code more scalable. It applies to Blueprints, too (after all, it was developed in C++)! (local functions, macros, collapsed node, function library)

Also, to cover up on the optimisations, you will have to learn, but not limited to, control flow, object references, interfaces, encapsulation, overriding, dynamic casting, class templates, namespaces, replication, iterators, and many more.

That’s the reason I could not help much in this context. It’s not something that can be explained in one single post.

isn’t there a way to make it in a blueprint instead of c++?

As I said, BP was made from C++. They are using the same structure as C++. Not Python, not Java, but C++’s structure.

C++ is a high-performance mid-level language considered optimised for game usage. That’s why they chose it. If you want to use your own structure on an intended (made from) C++ based design, you will get a bad practice code setup (non-scalable, not optimised, messy, too many variables, memory leak).

i got this working like a week after making this post, and i certainly didn’t need C++. Its pretty easy to do with blueprints and works great!

here is the code btw: Hello Neighbor Magnet Gun posted by anonymous | blueprintUE | PasteBin For Unreal Engine