|
Zed Kiergarten
Registered User
Join date: 19 Jan 2008
Posts: 138
|
04-06-2008 16:17
I'm looking for a script that can change the texture of a prim based on the proximity of an avatar. I had posted this over in the building forum, but basically I would like to have a texture that is slightly transparent that can turn totally transparent as you get closer. I've seen it in SL so I know it must be possible so am wondering if anyone knows of such a script.
|
|
Saladin Nightfire
Scripter for HIRE
Join date: 6 Jan 2008
Posts: 20
|
04-06-2008 17:05
i would assume you do not know how to use the sensors or LSL scripting?
What u may be able to do is just use the simple sensor to detect that avatars and then just take that and depening on location to the pos... it would do what u want
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
04-06-2008 17:14
This should work: default { state_entry() { llSensorRepeat( "", // Name of avatar (if you want a specific one) NULL_KEY, // Key of avatar (if you want a specific one) AGENT, // Type of object to sense 24.0, // Range PI, // Scan all around (PI_BY_TWO gives a semi-sphere) 1.0 // Repeat every 1 second, decrease this for faster responses ); }
sensor(integer x) { vector closestPos = llDetectedPos(0); // Index 0 is always closest vector myPos = llGetPos();
float distance = llVecDist(closestPos, myPos); distance -= 5.0; // The distance to become 100% transparent float alpha = distance / 20.0; // The distance to become 100% opaque
llSetAlpha(alpha, ALL_SIDES); } no_sensor() { llSetAlpha(1.0, ALL_SIDES); } }Change the ALL_SIDES constant for a number if you only want one face to disappear, you'll have to experiment with values till you get the right one. I've tried to comment as best I can so you know what each step does, for example, you can change the lines: distance -= 5.0 and float alpha = distance / 20.0 by editing the numbers 5.0 and 20.0 to adjust the invisible and opaque distances respectively. That is, at 5m and closer the object is fully transparent, while at 20m and above it is fully opaque (0% transparent). I've also dropped the script onto your profile, since the formatting here gets messed up with BBCode disabled.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Zed Kiergarten
Registered User
Join date: 19 Jan 2008
Posts: 138
|
04-06-2008 17:26
From: Haravikk Mistral This should work: Change the ALL_SIDES constant for a number if you only want one face to disappear, you'll have to experiment with values till you get the right one. I've tried to comment as best I can so you know what each step does, for example, you can change the lines: distance -= 5.0 and float alpha = distance / 20.0 by editing the numbers 5.0 and 20.0 to adjust the invisible and opaque distances respectively. That is, at 5m and closer the object is fully transparent, while at 20m and above it is fully opaque (0% transparent). I've also dropped the script onto your profile, since the formatting here gets messed up with BBCode disabled. Most excellent, you rock... thanks!! This worked exactly as required...
|