I can’t attach in game weapon to my fps character (fps demo and my own project from start). I have no problem with attaching weapon (or other meshes or blueprints) in 3rd person character. As I read and I see, here is skeletal/parenting problem. I read a lot of threads here, many with answers selected, but I can’t see any solution. Also, all web and youtube tutorials showing only how to attach on start - what is easy and logically or how to attach to 3rd person character.
I tried many ways, and always I fail. As I said, I can parent easy on 3rd person character, but I need it for fps character. I don’t want to create solution with child already attached and hidden on start - many reason.
Please help, I see this is common problem but I can’t see any reasonable and working solution. I did everything what I can following UE documentation and others tips, always fail.
Yes, I have sockets, as I said - I can attach to 3rd person skeleton and this should be similar way. Sockets and scripts ok, but here (fps) is strange parenting structure and I can’t find way how to do this simple thing - attach weapon in game.
I have title not solved, because I read few threads with answer selected and marked as solved, but it was not solved at all. This is more to problem not this question only.
“Get Player Character” gets the currently used player character. It assumes the type of the default character. The smallest common denominator. Every return value from “Get Player Character” will return a “Character” or “None” (nothing).
To access your own stuff. You need to cast the variable.
A cast basically asks “Are you of type X?”. So you need to ask the result of “Get Player Character”, “Are you of the type ‘MyScavanger’?”.
Aka “Cast To MyScavanger”. If it succeeds you get a reference of the type “MyScavanger” and from there can properly access “Mesh1P”.
Small personal suggestion. Try to avoid “Get Player Character”, “Get Player Controller” and similar nodes and try to pass on those variables correctly.
If your “InputAction Use” is inside of your character, use “Self”. If it’s within your player controller use “Get Owned Pawn” → “Cast To MyScavanger”.
Strange was bad word of course. It just confused me – sorry.
Here is fps structure:
I can attach to Mesh but this is mesh without skeleton. My character mesh where I have to attach something (eg weapon) is Mesh1P and I can’t call it from attaching procedure.
I tried your solution and I had similar before (one of my attempts). With ““Get Owned Pawn” → “Cast To MyScavanger””. I can get right mesh as parent, then weapon is ‘maybe’ attached but not visible - not sure where is attached, just disappear from his place. Socket is good for sure. I have weapon as blueprint if I not mentioned.
Here current blueprint code, cast to and mesh is different but correct:
I hope this is just you renaming everything. And not a completely different thing.
What’s the weapons location?
You keep the relative offset. Meaning it will only be in the specified location, if it’s moved exactly there before you attach it. Otherwise it will have the current offset.
Is “Use” firing? It seems you are attaching a weapon from within itself to the player. Fair enough but now you have to make sure that input is received.
Lol sorry with relative, I tried many settings and before for some reason ‘snap to target’ not worked. Now I have snap and is attached!
Is not on socked as I planed, but I will fix it, weapon bp itself is attached and is solved - thank you so much!