How to spawn objects on a restricted sphere surface relative to camera?

Hello everyone,

I’m trying to spawn targets at random positions relative to my camera with certain restrictions, however I’m having plenty of trouble getting the transformations right.

How can I spawn an object at some distance D from my camera with

  1. A random horizontal angle offset
    from my current orientation between
    [-hA, hA] where a horizontal offset
    would correspond to moving the mouse
    left/right.
  2. A random vertical angle
    between [-vA, vA] where vertical
    angle would correspond to moving the
    mouse up/down.

Thanks,
Tom.

look up spherical-to-cartesian conversion. it’s pretty straight forward.

lmk if you can’t find something that works for you.