Aurora.ScriptEngine.AuroraDotNetEngine.APIs.LSL_Api.llLookAt C# (CSharp) Method

llLookAt() public method

public llLookAt ( Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3 target, double strength, double damping ) : void
target Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3
strength double
damping double
return void
        public void llLookAt(LSL_Vector target, double strength, double damping)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            // Determine where we are looking from
            LSL_Vector from = llGetPos();

            // Work out the normalised vector from the source to the target
            LSL_Vector delta = llVecNorm(target - from);
            LSL_Vector angle = new LSL_Vector(0, 0, 0)
                                   {
                                       x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO,
                                       y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z)))
                                   };

            // Calculate the yaw
            // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system

            // Calculate pitch

            // we need to convert from a vector describing
            // the angles of rotation in radians into rotation value

            LSL_Types.Quaternion rot = llEuler2Rot(angle);
            //If the strength is 0, or we are non-physical, set the rotation
            if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
                llSetRot(rot);
            else
                m_host.startLookAt(Rot2Quaternion(rot), (float)strength, (float)damping);
        }
LSL_Api