Random point in rotated box

Hi guys,
need your help, I’m having difficulties trying to pick random points inside a rotated box.
Here’s the situation:

The camera is upside down (for complex and not modifiable reasons) and GetComponentsBounds / RandomPointInBoundingBox do not seem to take rotations in consideration.
Has any of you worked on something similar or has any idea to help me figure this out?
I would really appreciate it.
Thanks.

Generate a point as your box would be centered in 0,0,0 and with no rotation - just a random vector in range/bounds or what ever it’s called. Or you can always just generate 3 random floats in range and make vector out of them.
Then do a Transform(RandomPoint, GetActorTransform(Box)) this will translate your point into a world space aligned with box. You need to use TransformLocation node for this.

1 Like

I’m not sure I grasped what you suggested, but maybe it’s because it’s late and I’m tired.

The point I should randomly get, should be in a box of the same size as the rotated one, right?
Then I should do as in this picture? With T being GetWorldTransform of the Collison Box component, and Location being the random point in the surrogate box?
screenshot_31.png

3 Likes

Exactly but put origin input as 0,0,0

2 Likes

Yes, it made lot more sense in the morning :smiley:
It worked perfectly.
Thank you very much BoredEngineer.

I need to hunt you down and buy you a beer, I have been stressing on this for the last 2 days. Thank You

1 Like

I also need to hunt this guy down and buy him a couple of rounds,

been having this issue with a spawn-box & the vector rotation being inconsistent for a solid month. Hadn’t been able to narrow the issue down until I stumbled upon this post. Much appreciated.