I’m an amateur myself; I certainly haven’t started fiddling with the GUIutility operations, you may be on to something there.
Here’s a rudimentary example of the 3D pointer at work:
http://www.archonium.com/pointer_sample.html
It is set to point at the light source.
and the project file:
http://www.archonium.com/pointer_sample.zip
(open the “sample” scene)
it uses this script (along with standard FPS walker scripts):
var trigger_object: Transform;
var camera_object: GameObject;
private var target_created = false;
private var target : GameObject;
function LateUpdate () {
var screenPos = camera_object.camera.WorldToScreenPoint (trigger_object.position);
if (!target_created){ //should probably put this in Start()
target = GameObject.CreatePrimitive(PrimitiveType.Sphere);
target_created = true;
target.transform.localScale = Vector3(0.01, 0.01, 0.01);
Destroy(target.collider);
}
else //set the sphere position to right where the screen point is.
target.transform.position = camera_object.camera.ScreenToWorldPoint (Vector3 (screenPos[0],screenPos[1],0.35));
//tell the peg to turn towards the sphere
transform.LookAt(target.transform);
}
That script is placed on the “peg”, a sphere set at the pivot point for the pointer. The pointer itself is a child of that object. You could get by with a single object if the axis is properly placed.
a target is generated in world-space based on the screen-space of the position of the light source, directly in front of the camera, along with the pointer, which targets it with LookAt.
I used a cone pointer here because LookAt will cause some rotation around its forward axis that would be very evident with a 2D pointer.
I used a sphere as a target in this example instead of an empty game object to illustrate the method better. The sphere appearing to hover over the light is actually very small and right in front of the camera, on nearly the same plane as the pointer that targets it. These are both within the collider of the camera.
This method has its limitations, and as you can see there is a slight issue when the target object is directly on or behind the camera, but it’s fairly simple so good to work with for a start, I feel, and these can probably be solved with a few simple “If target is this close do this” and “if target is not visible” sort of things.
LookAt: Unity - Scripting API: Transform.LookAt
You may also want to take a glance at Quaternions; Quaternion.Lerp, and
Quaternion.FromToRotation;