Download

Why does "Get Local Bounds" of a Static Mesh not account for the rotation of the parent Actor

Hi. I have a wall. I have placed it in the world.
Its location is 1310, -290, 20.
The rotation is 0, 0, 0

I use the local bounds and then spawning an object somewhere into the wall.
That works.

But if I change the rotation to 0, 0, 90 by hard coding it in the Details panel and then run my code the local bounds seems to remain in the same place ie perpendicular to the wall that is now rotated by 90 degrees.

I don’t quite get why the Local Bounds of the Static Mesh also hasn’t been rotated 90 degrees.

Thanks.

Update: I did find this post:

https://answers.unrealengine.com/questions/584017/get-component-bounds-rotation.html

So I was wondering how would I then go about rotating the local bounds 90 degrees along the Z (yaw) axis?

Cheers

There is “rotate vector around axis” node, use it.

In unreal vectors are basically points in 3d space (and Epic wrongly names them as vectors, real ones should have tail point and head point).
Epic ones assume that tail is always at [0,0,0], but that simplifies vector math a lot, and suits very well for games.

So to get new bounding box, you need to rotate all those bounding box points (vectors) around Z axis. It will work for 90 deg, but for different angles you need to make your own function that check if something is inside bounding box.

However, you wrote you want spawn something inside boxy wall. There is different approach.
Think of it like shooting wall. First you shoot wall and find some point on its surface. Then you find second point where line of shoot exits wall. Then in middle between those points you have location perfectly inside wall. LineTrace node can find those points.

Better version of it, is that after finding point on surface of wall, you get normal vector to that surface at that point (its in hit results of line trace), then you move your spawn point inside wall.

Thanks. That makes sense. But what I actually wanted to do was a little bit of the reverse. Let’s say I have a wall modelled in 3dsmax and I know it is 100 height x 50 width x 20 depth. What I want to do is put an object on the wall at a random point on that wall. So when I import the wall into Unreal and place it in the world it has a certain location. But lets say I want to spawn a picture frame on the wall at a random location on that wall - that seems a bit complicated and then I need to use the bounding box because there is no other way to find a random point on the wall. (at least I don’t think so).