Download

Attach Object to Player with Spring Arm

Hello. I have an object that the player is able to pick up using an Attach Actor to Actor node. Sadly, when this object collides with some thing like a wall, it clips through. I think the solution to my problem is a Spring Arm component. I would like it so when the object attached to the player collides with something, it reacts instead of just clipping. I am unsure on how to attach the object and have the spring arm work in blueprint. Any help is greatly appreciated. Thanks.

I have something working along these lines, its a bit rough at the moment but the screengrabs should help.


It took me a while to get the springArm orientated correctly, but you should be able to read the values in the viewport screengrab.

PickupZone is just a ‘box collision’ sat at the end of the SpringArm, it gives us a reference point to attach the pickable item (attachee) onto. I also set this to non-hidden for testing in-engine because springArms are invisible.

3a0c5442295b36b79832c025724a23a0df8430d1.png

The script currently works with any physics-enabled actors in the level but it could me made more specific regarding what can/can’t be picked up.

the ‘noActor’ variable is just an unset actor variable, it is used to determine if there is anything stored in ‘attachee’ when we release the key.

‘pickupDistance’ is set to 200.0 which seems about right.

Really nice job. Could you try to help with my problem too? I am making a little project where I try to spawn debris on the ground, and it could be picked up to circulate around the player. Like this:

Képkivágás.PNG

Since they spawn on the ground, they have to have physics, then after pressing a button, the close ones go to the player. I made their path (even the round movement) with long formulas, and they work well, until the player start moving, because then as they try to catch up with the character they gather up into a ball, and continue their way in one bigger group (not a “nice full circle” as on the picture).
I tried to compensate it by adding the characters speed into the equation too, but they still accelerate too slow (best result if multiplied with 1.7, don’t know why).
So the best solution for me would be to attach them to the player’s relative coordinate system, so they surely will move together with the player, but it can’t be done with bodies with physics. Doesn’t even help, if I turn it off right before pick up.

Any ideas? :confused:

Hello, I’m new to blueprints and I kinda get the process of the blueprint. The only question I have is with the “attached” variable. Is this a BP? or what is the thing being referenced.