Change color of box collision

I’d like to change the color of the box collision during runtime for debugging purposes, is there a way to do it in blueprints?

I can only retrieve the shape color of the mesh but not set it

1 Like

In the Blueprint editor you can select the collision component you want as a different color. In the properties/detail panel under the Shape section. Drop the triangle to get more shape properties, change the color.

2 Likes

thats not quite what their asking. they are looking to do it at runtime so when the game is running not in the editor when out of play.

as far as i know there is no way to change the color at runtime in blueprints.

1 Like

If you set the color in the details and then while playing call up the command line and type “show collisions” you get the different colors in game for debugging.

I guess if they really wanted to change it dynamically during run-time they could rebuild the engine and change the UProperty in Shape Component

/** Color used to draw the shape. */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category=Shape)
FColor ShapeColor;

Or build a simple C++ function to Set it.

Just select the collider and under “Shape” make sure to expand all arrow menus.
For sphere colliders, the “Shape Color” is visible, but for cubes/Box Colliders and Capsule Colliders, “Shape Color” is hidden by the “Show Advanced” down arrow.
That’s how you change the color of the collider wire frame for spheres, cubes, and capsules.

Maybe you can access these values through the component during runtime?
I found this page simply looking for how to change the colliders colors for debugging purposes also, just not during runtime.

Oddly, in Blueprints, there is a Get Shape Color, but no Set Shape Color. At least in 5.1. I can’t think of a reason why you would ever want to get it but not set it.

1 Like

The only reason that comes to my mind is that these components were not supposed to be seen in game when they were planned, so these functions are not available.

One can set/unset the “hidden in game” setting. Maybe in the past that option was not available (and always “true” for a box), but that’s not the case anymore for sure.

And now, one can change the line thickness at runtime, but that’s a recent feature (UE5.1)