Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Quick Slew Of Questions

Rez Gray
Registered User
Join date: 2 Apr 2007
Posts: 23
02-17-2008 00:21
Hi. I'm gonna try and do a speed compile of a game system over next week. I had alot of questions I haven't worked out that I wanted to get help on.

1. How do I detect if a vector is behind my avatar?
2. What's the best way to figure out if a vector is hitting an AV's head, torso, or legs?
3. What's the best way, in LSL, to keep track and apply Diminishing Returns?

Okay, that's it for now. Just some stuff I'm mulling over.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-17-2008 01:03
1. Get your avatar's position and rotation (from an attachment this would be llGetPos() and llGetRot(); from a scanner, touch, etc. it would be llDetectedPos() and llDetectedRot(); you could also use llGetObjectDetails()), then:

CODE

vector avatarPos = ...;
rotation avatarRot = ...;
integer isBehind = llRot2Fwd(avatarRot)*(pos-avatarPos) < 0.0; // Dot product with avatar's x-axis dir


2. Hard to say. By "vector" in this case, do you mean a particular point, or the ray indicated by a point and a direction, or what? Generally you could determine how far from your center a point or line is, and how far in the z-direction relative to the center.... I suppose you could figure in llGetAgentSize(), but there's no way I know of that you can know relative head/torso/leg size, and basing location on the animations playing is pretty impractical.

3. As much as there is in other systems, except for LSL's communication and memory limits I suppose. You'd probably have to ask more specific questions to get a more useful answer though.