Why is an attached object not stopping the character from moving?

At run time, the character (a C++ class that inherits from ACharacter which is then derived in a BP for setting meshes) can pick up objects. When this happens, I do the following:

ObjectBeingCarried->AttachRootComponentTo(CapsuleComponent, NAME_None, EAttachLocation::SnapToTarget);
ObjectBeingCarried->AddActorLocalOffset(FVector(25.0f, 0.0f, 0.0f));

Where ObjectBeingCarried is the newly picked up object.

This does attach the object the character and when I move about, it comes with me. However, if I approach a wall, when the carried object hits it, nothing happens, the object passes through the wall. It is only when the character itself hits the wall am I forced to stop.

How can I make it so the attached objects collision shape is also considered when moving the character.

Hi ,

This sounds like the collision for the carried object is somehow being turned off when it is attached to your character. Try turning on collision bounds in the viewport (Show → Collision) then play your game in the Editor until you have picked up an object. Pause the game and Eject from your character, then zoom in on the object that you are carrying and see if you can see the collision boundaries around the object.

Ok, I will look in to this next week and get back to you, thank you :slight_smile:

I can confirm the collision mesh is still visible on the object and yet it is able to pass through the walls. Is there a way to ensure it is still set to block all?

Could you provide a screenshot of your collision settings for the object?

Attached are screen shots of

  1. the collision properties of the item that is attached to the player:
  2. the collision properties of the player:

Hey i have a melee weapon “axe” attached to my pawn/ character.
When i attach it to the player mesh (players picks up weapon) i use this line of code to avoid it colliding with the player.

OwningPawn->MoveIgnoreActorAdd(this); // Ignore the weapons collision on the player carrying it..

the use of (this) is the actual weapon and OwningPawn is the Pawn/ character holding it.

This is sort of the opposite of my problem! My problem is that the picked up item (e.g. your axe) does not collide with other things (such as the wall). The player is only halted once the player itself reaches the wall. The thing being carried, which is in front of the player, passes through the wall. Does this happen with your axe or is the axe collision considered when moving the player?

I have/ had the samme issue actualy.
Try to see if you have forgot to check / set the Generate Hit Events on the mesh or capsule. Of your axe, with some tweeking i can get it to colide.

I assume you mean “Simulation Generates hit events”? This wasn’t ticked but ticking it had no effect. I’d have thought all that did was trigger events when it collides with something. I connected a print to the hit event and it works before i pick the object up but fails to register hits after…

I did a real quick test of a similar setup and saw some behavior matching what you described. I have reached out to a developer to find out what the best option may be to adjust the collision behavior in this instance.

Great, thank you :slight_smile:

This is because when we sweep a component in MoveComponent(), we only sweep the root component and then teleport attached children, regardless of whether they are blocked along the way.

Some people have proposed an option to sweep all of the components and take the closest blocking hit and only move that far. I think there are probably many complexities with going that route though. Anything that just wants an impact is probably fine (like a projectile that explodes on impact). Anything with more complex movement could have issues. Most of the movement code and game code presume that the blocking hit returned is relevant to the root component, so any filtering based on distance to radius or angle of the normal breaks down. For instance if a sword hits a wall, how do you determine the normal to slide along, when it’s usually based on the smooth capsule normal? Compute a new one assuming it was a capsule at that radius instead? Use the impact normal?

Also, what if there is a sword animation that moves the sword forward to impact the wall… should the animation know to stop there, should it push the player back, or just pass through?

It starts to get messy, but it’s come up a few times, so it’s something we’re thinking about.

I have been experiencing the same problem. Were you able to figure out a workaround for this ?

Hi kaos,

Refer to the answer provided by Zak Middleton. This is currently working as intended, though we are considering ways that this can be improved.

Thank you ,. I will have to figure a way to push objects without attaching them to the player then.