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
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
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.
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.
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.
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)
Not sure possible direct in BP, but perhaps this would help: if you create a C++ child class based on UBoxComponent you can directly access the Protected LineThickness variable, create a Public SetLineThickness(float NewThickness) { LineThickness = NewThickness; } function which you can then call.
You could probably do this by creating a child blueprint class of a UBoxComponent and creation of a Blueprint function?
I clearly remember I tried to do this last year and this wasn’t possible since the color/thickness variables were not accessible in child classes, I literally had to re-implement a custom arrow component copying the original one and exposing some functions to BP😅
You can do it with an editor utility blueprint of type EditorUtilityActorComponent, this will let you call SetEditorProperty and change the variable even though the setter isn’t exposed to blueprint.
Let me add that while I gave a solution to do what you want I think there are much better way to do it, like adding a simple text render component and changing its color, or basically any other visual feedback.
Keep in mind that editor utility blueprint won’t be present in your packaged game so you be able to debug there.