Announcement

Collapse
No announcement yet.

Simple Question about applying a texture to a COLLISION BOX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simple Question about applying a texture to a COLLISION BOX

    Hey all,

    I'm fairly new to UE4 and game development in general. I have some previous C++ experience as well as level design experience (using other game's editors). I have my Blueprint working as intended but this is more of a quality of life question for designing my levels. I've setup a simple death blueprint to replace the basic KillZ volume. It's using a simple construction script to allow the size to be adjusted in the editor. I'm typically using this as at very large sizes to cover if a player falls out of the world.

    My issue is that it's very difficult to tell exactly where the top of the box is. In my previous level design experience (mostly for Quake 3) I'm using to having trigger volumes with semi-transparent textures so you can see where the faces are. I'm hoping to recreate this in the editor view (visible in game and collision will be turned off). Here's the problems:

    1) You can't apply a texture to a collision box (afaik)
    2) I can apply the texture to a cube but I don't know how to then scale that cube to match the size of the collision box. This is because the collision box uses the Box Extent properties for X,Y,Z which are sizes and the a cube simply uses X,Y,Z scale multipliers.

    Is this possible and how would you go about doing it? Thanks!

    I'm including images of my full setup... again it's functioning fine (although I'm open to alternative methods if I'm doing anything wrong!), I just want to add in a visual representation so I can tell where the faces of the box are in the editor.
    Attached Files

    #2
    How I would do this is to have in an Actor Blueprint, a Cube Static Mesh component, with a Box component as its child. Child components inherit the scale of their Parent components. So you could scale the entire Blueprint (or just the Cube if you want to set that up with Construction Script) and the Box component will scale along with it. As long as you setup the Box component to be the same size as the Cube Static Mesh Component, when the Cube is at a scale of 1.0 for X,Y, and Z, then they'll match perfectly. I found that having the Cube at a 1.0 scale, and the Box extent set to 50 for X, Y, and Z, the Cube and Box are the same size.

    A few things to watch out for:
    - Make sure to turn off collision for the Cube
    - Set the Cube to be Hidden in Game; don't use a transparent material, as this will incur an expensive rendering cost
    - If you need to get the extent of the scaled Box component, use the Get Scaled Box Extent function, which returns a Vector3 for the X, Y, and Z extent of the Box, as if it wasn't scaled but had its extent manually set

    Useful images:

    Component Hierarchy
    Click image for larger version

Name:	Component Hierarchy.png
Views:	1
Size:	8.3 KB
ID:	1127268

    Cube Collision settings
    Click image for larger version

Name:	Cube collision settings.png
Views:	1
Size:	14.4 KB
ID:	1127269

    Use GetScaledBoxExtent
    Click image for larger version

Name:	Using GetScaledBoxExtent.png
Views:	1
Size:	60.7 KB
ID:	1127270

    Blueprint in Editor
    Click image for larger version

Name:	Blueprint in Editor.png
Views:	1
Size:	691.1 KB
ID:	1127271

    Blueprint during Gameplay but with Box component Visible in Game
    Click image for larger version

Name:	Blueprint during Gameplay but with Box component Visible in Game.png
Views:	1
Size:	710.7 KB
ID:	1127272

    Comment

    Working...
    X