I’m struggling a lot to make a simple feature of my game work.
In my game I have a vehicle on which you can attach extra parts (tools, weapons, etc …). An extra part is an independant Actor that by default lays on the ground and that can be picked up and attached to the vehicle.
Here a simple example, you can think of the extra part as some sort of vehicle tunning to bump into zombies during an apocalypse. (the image is not from my game, it is just for the example)
What I need is that, when I’m driving my car, the bumper has to collide with other actors.
However after many days lost on this, I cannot make it work. The bumper always overlaps any other actors when my car run into them. For example, I smash the car into a wall, the bumper will overlap and only the car will collide. However the bumper collides properly with other actor when not attached to the car.
I’m attaching the bumper via C++ (but it’s the same with the AttachToActor Blueprint node)
I needed to create a UPhysicsConstraintComponent attached to the car skeleton, then apply the constraint between the bumper skeleton and the car skeleton.
Now I got my collisions perfectly working ! When I drive the car into a wall, the bumber collide and the whole car stops without the bumber passing through the wall. Hope it helps someone else.
Below the variables are :
BumberSkeletonComponent : the SkeletalMeshComponent belonging to the bumber actor
CarSkeletonComponent : the SkeletalMeshComponent belonging to the car actor
SocketName : the attachment socket on the car skeleton