Hey guys,
As the question sais I am mainly and artist but Im trying to get the hang of BP.
What I want to do is have a sword in the world and if i walk near it I can pick it up wiht E and is automatically equipped into my hand. (only available for pickup if i am close and cursor is overlaping the sword[basically im looking at it])
However I didnt find much usefull information out there guys so this is why I am here.I would be very thankful if soemone could help me out or even point me in the right direction so i can actually start putting together my assets into an actual game.
You will want to attach the sword using the socket bp nodes (See reference document above). Simply create a On Key Press event for the “E” key, do a raycast to see if you hit the object, and if true, bind the object to the socket.
Well, first things first. I tell this to everyone, but learn to use Interface blueprints, it will make your life MUCH easier, and help you get away from messy Cast To nodes. Not going into great detail on what needs to be done with those unless you need me to, though.
Secondly, you don’t. You take an object reference from the the raycast, and either use an interface to call a function on the object (best solution), or use something heavy handed like checking it against “get all objects of type” or “get all objects with tag”. There is also the option of using a “Trace By Object” which only returns objects of a given type. However, those are really, really messy and heavy handed. Use interfaces, interface functions can fail silently which makes them particularly useful for these types of instances.
Create an interface function, and have the function perform all of your binding. When the user presses the E key, call that function on the object return from your hit. If it doesn’t have it, it will fail silently.