Spawn on a sphere

Hey all,

Here is an interesting one:

I’m in search of a blueprint that would let me spawn objects on a sphere, something like this:
image

either an unreal sphere, an FBX sphere, using vertex positions,
or no actual spere at all just calculations.

Is that possible?

The location and rotation should be calculated so the objects are pointing outwards.

Thanks a lot!

Pick a random unit vector; Spawn thing with location = SphereCenter + RandomVector*SphereRadius, the rotation can be set from the same RandomVector, add extra constant rotation if it isnt enough.

If you need to pick point from mouse, then something like ConvertMouseLocationToWorldSpace, but then you isn’t limited to sphere

Would that result in a consistent placing? I’m looking actually for the opposite of random,
more like accurate placing on the vertex,

image

Is that possible?

Thanks a lot

The principal is still the same, just pick the vector somehow meaningfully.

Not 100% sure i wrote the math correctly, but something along those lines should work

float VerticalStep = 10;
float HorizontalStep = 20;
float Radius = 1234;
for(float i = 0; i < 180; i+=VerticalStep)
    for(float j = 0; j <= 360; i+=HorizontalStep)
    {
       FVector Dir = FVector::UpVector;
       Dir = Dir.RotateAngleAxis(i, FVector(0,1,0));
       Dir = Dir.RotateAngleAxis(j, FVector(0,0,1));
       DrawMyObject(Center, Radius, Dir);
    }

Maybe HorizontalStep should also depends on VerticalStep instead of being independed constant value

I’m not so great with coding, so I’m using Blueprints only, therefore I’m not so sure how to Blueprint this code.

update! found this tutorial, will have time tomorrow to try it out:

Also !
Found out about this:

The Procedural Content Generation Framework (PCG)

But this scheme is just a random sketch that does nothing, I have no clue how to get it into actual points in a regular blueprint, this is a special one:
image