Download

Get random points on a sphere surface to spawn actor.

Hello everyone,
I’m struggling with a BP and I need some help. I’m trying to spawn an actor on the surface of a sphere randomly, the actor need to be pointed toward the center(it’s basically a bended cylinder who need to stick to the surface). I tried with the node ‘‘Random point in bounding box’’ but I realized that the bounding box was not spherical. Anyone have an idea on how to proceed? Thanks!

If the surface is always going to be a uniformly scaled sphere then you can get a random vector, normalize it, multiply by the radius, and add to spheres location I think

Edit: and to make it point at the center, set the rotation to be the opposite of that random vector

Gonna try that, thank you!

It work perfectly for the spawning, but the meshes are not pointed to the center, they spawn pointed to the ground, do you have any idea how to fix this?

You’re feeding the spawned object rotation of the parent (or default rotation); you need to make a new rotation based on the directional vector, something like this:

Make sure cylinder’s pivot is at the base, not in the middle. Also, you can skip *normalise *in your example, random unit vector is already normalised.

Thank you for this detailed answer, that’s probably going to be useful later. But after some tests I found something simple that seems to work perfectly for what I wanted to do, thanks again fo the help!