Heads-Up Display
Introduced in
SL 1.7, the 8 heads-up display (HUD for short)
attachment slots are visible only to the
user to which they're attached. They're intended to allow
scripters to create
user interface elements, such as speedometers, game buttons, health readouts, etc.
Despite being invisible to other users, HUD attachments are just like any other attachment: they can be scripted, can automatically attach to an
avatar, and can communicate via
chat and
other methods.
Values for
llGetAttached and
llAttachToAvatar:
Value | Position |
31 | HUD Center 2 |
32 | HUD Top Right |
33 | HUD Top |
34 | HUD Top Left |
35 | HUD Center |
36 | HUD Bottom Left |
37 | HUD Bottom |
38 | HUD Bottom Right |
HUD attachments can be moved around the user's screen:
llGetLocalPos can be used to get the HUD attachment's current
position. (Notice that this isn't the same as
llGetPos which seems to tell the avatar coordinates instead of the HUD attachment coordinates.)
llSetPos sets position.
How HUD Positioning Coordinates Work
(Being familiar with
vectors will help.)
Each HUD attachment point has its own origin point,
<0,0,0>. Only the
.y and
.z components are used for positioning, so an example position might be
<0.0, 0.2, -0.8>, where
0.2 is the value of the horizontal axis and
-0.8 the value of the vertical axis. The
.x component is used to determine which HUD overprints when two HUDs overlap. More negative
.x HUDs will render on top of less negative ones.
Rather than the more traditional
coordinate layout, where numbers get bigger the farther up and right they go on the grid, the numbers on the horizontal axis of HUD attachment grid get larger as they move towards the
left side of the screen. (Fortunately, the vertical axis is normal -- larger numbers are higher on the screen, smaller numbers are lower.)
The grid the HUD uses is square, not
scaled relative to the size of the
SL window, so setting an attachment in the HUD bottom right slot to a position of
<0.0, 1.0, 1.0> will
not put it in the upper left corner. However, it
will put it at the top of the screen -- the HUD grid scales with the height of the SL window.
HUD attachments can still be positioned vertically without any trouble, as long as it is known where they're attached, but horizontally is another story. Because each attachment point is relative to window size, it'll end up vertically where desired.
This means that you can use the upper or bottom corner attachment slots to position an attachment in the corner above or below it, and be certain that it'll end up there on everyone's computer.
However, an attachment
can't be positioned to one of the corner slots to a position on the
opposite side of the screen with any reliability, as the dimensions of the SL window will change from computer to computer. (Note: there is no way to determine a user's window dimensions or aspect ratio.)
Note: It is now possible to find screen width using the new llDetectedTouch* functions. The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points.
default
{
touch_start(integer total_number)
{
vector scale = llGetScale();
vector off_point = llGetLocalPos();
vector face_pos = llDetectedTouchST(0);
vector screen_pos = llDetectedTouchPos(0);
float screen_width = ((face_pos.x-.5)*scale.y-off_point.y+screen_pos.y)*2;
llOwnerSay((string)screen_width);
}
}
The range of possible coordinates for HUD attachments is greater than
<0.0, -1.0, -1.0> to
<0.0, 1.0, 1.0>, but the actual position
llSetPos will move the attachment to appears to be unpredictable when the origin point of the attachment passes offscreen.
HUD Quirks and Workarounds
"Solid" HUD attachments
One frequent complaint about the HUD system is that even when fully
transparent, HUD attachments still don't allow clicking "through" them to the world behind. One workaround for this is to use
llSetPos to reposition the attachment offscreen when necessary for it to be "invisible". Note that in SL 13.0.8 (not sure which version this started in) you can use the mouse-wheel to shrink the HUD layer to the center of the screen (making the majority of the screen useful again).
Particles appear at <0,0,0>
When using
llParticleSystem in a HUD attachment,
particles will appear to come from
<0,0,0> in the
sim, not the HUD attachment. There is no workaround. Don't use particles in HUDs.
Q: Is it possible to trigger a sound in a HUD attachment that only the owner hears?
A: Yes. llPlaySound in a HUD attachment will only be heard by the owner.
A: You can also use llTriggerSoundLimited using llGetPos as both vectors which would give that headphones effect. (Incase you want to use a triggersound function) --
DarwinRecreant
Attachment |
User Interface |
AgentAndAvatar |
Jasa SEO Jasa SEO Murah Sepatu Online Toko Sepatu Online Sepatu Sepatu Murah Sepatu Safety Sepatu Futsal Cheapes Hostgator Coupon Link Booking Televisori offerte Notebook Offerte Berita Terkini Internet Marketer Muda Internet Marketer Indonesia Portatile Apple RDAnet Lorks Karikatur Bisnis Modal Kecil Bisnis UKM Berita Terbaru Iklan Baris Jasa SEO Jasa SEO Murah SEO Indonesia Konsultan SEO SEO Belajar SEO Kursus SEO Kursus SEO Murah Jam Tangan Casio Jam Tangan Casio Jam Tangan Murah Jam Tangan Grosir Baju Terbaru Grosir Baju Baju Terbaru Grosir Baju Murah Bisnis Online Belajar SEO Kerupuk Kerupuk kulit Social Bookmark Dofollow Social Bookmark Kumpulan Puisi Kirim Puisi bola hantu Penumbuh Rambut Penumbuh Rambut timbangan WBC Wonogiri Jasa SEO Murah Jasa SEO Jam Tangan Murah