Enabling & Disabling Box Collision In Character Blueprint

Hello all, got a collision question for you.

So I am attempting to make a character that allows the player to swap between different shapes to navigate puzzles. There are 4 different shapes: CUBE, SHPERE, CONE, CYLINDER. When the player wants to swap to a different shape, the collision volume adjusts to better fit the player.

Here’s the problem: the CYLINDER shape is long and wide, and doesn’t fit the CAPSULE COLLISION well in the character blueprint. So to circumvent this, I added a BOX COLLISION to the CAPSULE COLLISION, and tried to set it so that the BOX EXTENT fits the CYLINDER when swapped, and is smaller than the CAPSULE COLLISION when the player is a different shape. This initially didn’t work, as the collision wasn’t blocking anything, just overlapping.

I then discovered that you can get the BOX COLLISION to work by setting the CAPSULE COLLSION to SIMULATE PHYSICS, then immediately turn it off. The problem with this is that now the BOX COLLISION will always block, even when you swap to a different shape - it’ll even remember what the BOX EXTENT was and will disregard a newly set BOX EXTENT that is smaller.

So my question is this: how can I make it so that the BOX COLLISION is only ACTIVE when the CYLINDER is being used, but INACTIVE when any other shape is used?

POST NOTE:
I also tried to build the shapes as separate actors, and combine them into the character using a CHILD ACTOR COMPONENT and swaping the child actor out, however this still isn’t giving me the desired collision I’m looking for either. The BOX COLLISION added in the CHILD ACTORS is not being registered in the PARENT, and the player clips WORLD STATIC objects.


Capsule component in parent component


Box collision in child actor blueprint


Example of swapping blueprints


Example of my custom swapping macro

More screenshots can be provided, but hopefully this is sufficient. Thank you in advance for your help.

When you swap the shape, are you just changing the static mesh? Because then you could use the collision of the static mesh and you wouldn’t need those extra collision boxes(?).

Tried this method already, and while it ma say it is enabling/disabling collision it is not showing it in game. I am still able to pass through objects.

Yes. I am just swapping the static mesh.

I have the collisions of the individual meshes set up, and removed the extra collision volumes. However, I’m still getting the same issues. When I use the “Sim Physics On/Off” it works for a moment, but when I swap shapes the collision of each previous shape is remembered for some reason.

Example: Below I just swapped from CYLINDER to CONE. I should be able to get right next to the wall, but It thinks there is still a CYLINDER blocking me.

Another example of going from CONE to CYLINDER. It thinks the CONE is still there, so the CYLINDER is now floating.

Lastly, not using “Sim Physics On/Off” gives 0 collision on the static meshes, as the only thing recognized is the CAPSULE COMPONENT.

I’m going to continue different options to see what I can do, but please keep the suggestions coming :slight_smile:

Press 1 for switching the shape
Press W A S D for movement input

SOLUTION FOUND:

Thanks to everyone that responded, but I was able to find a solution after some tinkering to the blueprint nodes. Here’s what I found:

The issue seemed to be a combination of ENABLING/DISABLING collision on the STATIC MESH, and SIMULATING PHYSICS on the CAPSULE COMPONENT in a particular order. I found that you must perform these actions in this order to get the desired effect:

  1. DISABLE STATIC MESH COLLISION
  2. CHANGE THE STATIC MESH
  3. SET SIMULATE PHYSICS ON CAPSULE COMPONENT TRUE
  4. ENABLE STATIC MESH COLLISION
  5. SET SIMULATE PHYSICS ON CAPSULE COMPONENT FALSE.

Here’s how that looks in the graph:


This causes no noticeable issues with the in game collision, but I don’t know if this is going to eventually cause a performance hit. It’s a small game, so I might not see one, but for larger project this might be a poor method.