Download

Create a box from within a blueprint

I’m trying to create some boxes from within a blueprint.

When you use the brush to create a box, it is with a material and such.

However, when I create a box with “AddBoxComponent” from my blueprint, it makes a box alright, it is just not visible. I see the outline of it fine, so it is there. But the material I set it to use is not used. So in effect, there is no box.

Can someone help me out?

Here is my blueprint.
https://farm8.staticflickr.com/7013/13463870593_ec81d611f5_o.png

Hey Rasped,

A box component is used primarily for collisions and overlap events. They don’t have a “surface” so to speak.

It sounds like you might want to add some static mesh components and specify a cube as the mesh you want to use.

You should use this static mesh:
StaticMesh’/Game/Shapes/Shape_Cube.Shape_Cube’

It is in your Content Browser

The problem with this is… I need different sized boxes… and when I scale the object, it stretches the material I apply…

Heya Rasped,
You can accomplish this by using a Dynamic Material Instance and a Scalar Parameter in your box’s material. A blueprint to generate your static mesh, assign the Dynamic Material Instance, and set the parameter in your material to the average scale of the Actor:

Then your material will look something like this:

Note the name of the Scalar Parameter (UnifiedScale) matches what’s in the Blueprint’s Set Scalar Parameter Value (Parameter Name pin), and you should it’ll end up working pretty well:

There are plenty of ways to make this better, as depending on UV’s things can end up looking wrong, and if you scale along just one axis the material will scale uniformly.