How to target the object BP your character is "holding".
Hello! I'm working on a third person project where I want my character to be able to pick up an object, let's say puzzlepiece for simplicity, and attach it to sockets on a wall. The puzzlepieces are all duplicates of eachother, and will spawn when killing an enemy in game. Then, for the placing event, I want to add them to the sockets in a specific order (first to socket 1, then 2, then 3 etc). But I only want you to be able to place the puzzlepiece your character has attached to their hand socket (the piece your "holding"). Currently, I have a line traces set up so that I can attach any of the duplicate pieces to my character, and for the placing event, I have a boolean check after the line trace so that you can only attach a puzzlepiece if your character "is holding" one. But the problem is that when I trigger the placing event, it only attaches one of the pieces (the "original" piece, i.e. not a duplicate). I'm really new to all forms of programming and have a hard time figuring this biz out. Any advice is helpful!
Oh right, my blueprints for y'all:
The grab event, in the puzzlepieces' BP
The line trace to trigger grab event in characters BP
The place (attach to wall) event in the walls BP
The line trace to trigger place event in characters BP
asked Mar 23 '16 at 06:14 PM in Blueprint Scripting
Hi tamakerii i think/hope i can help, i think the reason why only the first 'Code Piece' is being used/attached is because the array variable of 'Code Piece'(s) is going through the get node and you're always getting the first one in the list, which counts up from 0, 1, 2, 3 etc.
One way you i think could add the puzzle pieces to socket 1, 2 then 3 is to right click on the green pin on the get node and promote it to a variable called 'Which Socket', set the value to 0 so it will get the first code piece in the array which is 0, after you've set 'is Filled?' add a get 'Which Socket' node, drag out of it and add a float + float node and change is so the maths is get 'Which Socket' + 1, then drag out from the output of that lasts node and make a set 'Which Socket'
What this should do is the first time you call 'PlaceCode' you attach 'Code Piece' 1, then you set the next code piece to be attached is 2, and the next time you call you attach code piece 2.
answered Mar 23 '16 at 07:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here