Jump to content

LSL function that retrieves the LookAt?


paratracker
 Share

You are about to reply to a thread that has been inactive for 3164 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

You need to calculate it.

 

llRotBetween(<0,0,1>,llVecNorm((TargetPos - llGetPos())));

 

Thats the global rotation for the z axis to your target

If its linked you need to divide the result by the roots global rotation.

This simple calculation will rotate the prim/object around the z axis. Ok for a single barrel but not ok for a turret like movement.

There are rotation tutorials but I can't link here.

This one is linkable: http://wiki.secondlife.com/wiki/User:Void_Singer/Rotations

Link to comment
Share on other sites

I'd give you the link to the answer I just posted to your identical question in Answers, but it's just as easy to cut/paste it here again.....

You can't, because there is no such LSL function.  You can answer some of the questions that you might be trying to address in other ways, though.  For example, if you're in mouselook you can use llCastRay to figure out what is along the vector between you and wherever your camera is pointing.  This code snippet

            vector start = llGetCameraPos();            list results = llCastRay(start, start+<50.0,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,5]);

will direct a cast ray 50.0 m from you along your line of sight and will return the UUID and position of the first object that lies along that path.  That's considerably more reliable than the notoriously sloppy LookAt function in your viewer.

ETA:  If you want to point your arm in the direction, all you really need is an anim that raises your arm and points straight ahead. Trigger it in the same event that triggers your cast ray and then turn it off a few seconds later with a timer.

Link to comment
Share on other sites

You want to point at a certain spot?

That's problematic. You can not move your arm by script. You can play an animation and you need one animation per angle.

That's the height. Now left/right. You can not rotate the avatar by script. You can sit on something. With a standing animation nobody will see that you sit. So you can rotate that way.

Another way is a 2nd set of animations working on shoulder/chest/abdomen area. Schould be good for +/-30° without breaking your back. :D

Or a combined animation for height and left right but that sums up pretty quick if you want a better resolution than just the quadrant.

Well pretty complicated and alot of animations and work. You will need your AO off or an AO with lvl 3 animations so your lvl 4 animations can override that.

 

Link to comment
Share on other sites

Given those (posing) complications, rotating the emitter prim so it points at the target eliminates most of the messy stuff.  The problem is thereby reduced to capturing a desired rotation, so we know how much to rotate the emitter prim.  I thought grabbing the LookAt would be better than jumping in and out of mouselook.  Alt-click, prim rotate, emitter on.  Is there nothing other than dropping into mouselook available for obtaining a direction vector?

Link to comment
Share on other sites

The only thing I can think of is rather like a hud. Imagine you have an object rezzed consisting of a circle and cross-hairs, which you an move around my means of the cursor key. Also imagine that it is rotating around you using one of the techniques mentioned in the wiki for rotating an object around a fixed point. You can therefore at any moment obtain from this object it's rotation relative to you, and possibly therefore the information that you want?

ETA I just tried this very quickly inworld with an attachment. I turned to face the four cardinal compass directions and got the llPos() and llRot() recordings from the attachment and they did seem to change as I turned. Therefore you can get the avatar rotation easily. If you then have an item such as I described which is set to rotate around you in a circle according to some form of control, you can at any time get it's rotation realtive to your own rotation using the individual rots of each.

I'm proposing this because I think we've all got side-tracked on the issue of raising an arm, but I see what you wanted originally was to use the LookAt target, which implies you want to move the pointer around the screen under mouse control, and when you click it, get the relative angle from yourself that the mouse pointer is at. Something like that already happens if you use double-click-auto-pilot, but as with the lookat, that is also not available to us via LSL.

Link to comment
Share on other sites

somewhere in this forum way down in a post, Dora posted a code solution which I think will help solve your problem

the solution was rotating a child prim on a attachment to track the camera. So that the prim/emitter is always pointing at what the camera/avatar is looking at. In both mouselook and normal view modes

i just cant find it in the search at the mo. but is defo on here somewheres

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3164 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...