Download

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:

6471d78341b26981c3776c08b699ea7461a37fda.png

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.

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

Exactly but put origin input as 0,0,0

1 Like

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