I have a sphere (sphere A) and I place numerous smaller spheres (sphere n) on the surface of that sphere, at various locations.
Attached to each of these smaller spheres (n) is a ParticleSystem component.
My particle systems all point the same direction… I’d like to rotate these smaller spheres (n) to point away from the center of the parent sphere (A). In other words, for a given point on a sphere (xyz), I would like to have another object, at that point, face the same direction as the normal.
Maybe this image will be more clear. The centre red dot is the centre of the sphere (A). The other dot on the outer is my smaller sphere position (n):
Any ideas?
UPDATE
After searching for ages for the answer, and then finally posting… I decided to search some more and have managed to find the solution:
In case, for whatever reason, that post gets changed or the link dies, here is the code that helped me:
// In this case, the normal is more useful!
Vector3 groundNormal = transform.position - sphere.transform.position;
// Here we work out what direction should be pointing forwards.
Vector3 forwardsVector = -Vector3.Cross(groundNormal, transform.right);
// Finally, compose the two directions back into a single rotation.
transform.rotation = Quaternion.LookRotation(forwardsVector, groundNormal);