I have solved the issue by adding an extra cube, two collision channels and playing around with collision, simulate physics and collision channel settings.
Collision Channels
I added 2 new collision layers: InvisibleCollider
, GrabbedObject
Grabbable Cube BP:
1. ParentCollider
- This is the main parent of the BP. It is a box collider with collision object type as
InvisibleCollider
and it is set to “Ignore” anyInvisibleCollider
. - This has simulate physics enabled.
2. VisualCube
- This is a cube that is child of the
ParentCollider
component. - This is the cube that is visible by default for all grabbable cubes.
- This one has simulate physics off so that any grabbed object will not affect it.
- Auto weld is disabled.
3. GrabCube
- This is the cube that the character will use for grabbing.
- Collision is set to false by default and visibility is off.
- Collision object type is
GrabbedObject
- Auto weld is disabled.
Events
1. Grab object
- Enable physics, visiblity an simulate physics for
GrabCube
- Disable collisions for the
ParentCollider
andVisualCube
- Disable visibility of
VisualCube
- Disable simulate physics for
ParentCollider
Grabbed object: Because of the settings above, the visual cube and its parent collider will not work now in the grabbed cube.
Other objects: Even though the ParentCollider
has physics enabled, it also has ignore for grabbed object, so the grabbed cube will not affect it. The VisualCube
on the other hand has simulate physics disabled, so that will also not be affected by the grabbed object. Setting auto weld to disabled makes sure that it does not start simulating along with its parent, the ParentCollider
.
2. Drop object
Mostly just the opposite of grab object with one extra step - Copy the location and rotation from GrabCube
and assign to VisualCube
.