Transparency Script with Collision
|
|
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
|
08-21-2008 06:44
excuse me, i'd need help with this script. i'd want one transparent bridge that appears when an avatar walks above. i've done this script: //script traparency fade with collision
float f_alpha = 0.0; float f_step = 0.05; //alpha change speed
default { on_rez(integer start_param) { llResetScript(); } collision(integer num_detected) { f_alpha += f_step; if (f_alpha+f_step > 1.0) {f_step = -f_step;} if (f_alpha+f_step < 0.0) {f_step = -f_step;} llSetAlpha(f_alpha,ALL_SIDES); } }
but i have two problems: - first i want that the prim is always transparent if anybody walks above - second i want it remains visible if there are avatars above now if you try the script and you are above the prim, you see that the prim continues becomes visible and full transparent continuously thanks everyone would help me 
|
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
08-21-2008 08:39
Indiana Jones and the Last Crusade, huh?  Instead of collision, use a collision_start event to make the bridge visible and a collision_end event to make it invisible again.
|
|
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
|
08-21-2008 10:02
From: Dylan Rickenbacker Indiana Jones and the Last Crusade, huh?  eheh  From: Dylan Rickenbacker Instead of collision, use a collision_start event to make the bridge visible and a collision_end event to make it invisible again. could you help me to insert in the right place please?
|
|
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
|
08-21-2008 10:30
i've done this simple script with collision start and end: //script traparency fade with collision
float f_alpha = 0.0; float f_step = 1.0; //alpha change speed
default { on_rez(integer start_param) { llResetScript(); } collision_start(integer num_detected) { llSetAlpha(1.0, ALL_SIDES); }
collision_end(integer num_detected) { llSetAlpha(0.0, ALL_SIDES); } }
but i'd like that the prim becomes visible and invisible gradually you could help me again? 
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
08-21-2008 11:48
I think this does the trick. From: someone float f_alpha = 0.0; float f_step = 0.1;
default { collision_start(integer num) { while (f_alpha < 1.0){ f_alpha += f_step; llSleep(0.2); llSetAlpha(f_alpha,ALL_SIDES); } } collision_end(integer num) { while (f_alpha > 0.0){ f_alpha -= f_step; llSleep(0.2); llSetAlpha(f_alpha,ALL_SIDES); } } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-21-2008 11:55
I'd probably do something like this. Normally I wouldn't use states so prolifically, but the different handling of events in this one and the fact that it makes things very understandable in this script make me more inclined toward it. (Note: Hasn't yet been compiled; may require a couple small syntax fixes.) float APPEAR_PERIOD = 0.5; float DISAPPEAR_PERIOD = 0.5; float DISAPPAEAR_DELAY = 0.5; float FADE_UPDATE_PERIOD = 0.05;
float transitionStartTime;
default { state_entry() { state invisible; } }
state invisible { state_entry() { llSetAlpha(0.0, ALL_SIDES); }
collision_start(integer nDetected) { transitionStartTime = llGetTime(); state appearing; } }
state appearing { state_entry() { llSetTimerEvent(DISAPPAEAR_DELAY); }
state_exit() { llSetTimerEvent(0.0); }
collision(integer nDetected) { float time = llGetTime(); float t = (time-transitionStartTime)/APPEAR_PERIOD;
if (t >= 1.0) { state visible; }
llSetTimerEvent(DISAPPAEAR_DELAY); llSetAlpha(t, ALL_SIDES); }
timer() { float time = llGetTime(); float t = (time-transitionStartTime)/APPEAR_PERIOD;
// Back calculate disappear start time for same alpha transitionStartTime = time-(1.0-t)*DISAPPEAR_PERIOD;
state disappearing; } }
state visible { state_entry() { llSetAlpha(1.0, ALL_SIDES); llSetTimerEvent(DISAPPAEAR_DELAY); }
state_exit() { llSetTimerEvent(0.0); }
collision_start(integer nDetected) { llSetTimerEvent(DISAPPAEAR_DELAY); }
timer() { transitionStartTime = llGetTime(); state disappearing; } }
state disappearing { state_entry() { llSetTimerEvent(FADE_UPDATE_PERIOD); }
state_exit() { llSetTimerEvent(0.0); }
timer() { float time = llGetTime(); float t = (time-transitionStartTime)/DISAPPEAR_PERIOD;
if (t >= 1.0) { state invisible; }
llSetAlpha(1.0-t, ALL_SIDES); }
collision(integer nDetected) { float time = llGetTime(); float t = (time-transitionStartTime)/DISAPPEAR_PERIOD;
// Back calculate appear start time for same alpha transitionStartTime = time-(1.0-t)*APPEAR_PERIOD;
state appearing; } }
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
08-21-2008 18:06
haha, hewee. i tried it. it compiles as is, but the bridge continues to appear and then fade out over and over after someone has initialized it by walking on it (whether they're still on it or not)
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-21-2008 21:17
From: Ruthven Willenov haha, hewee. i tried it. it compiles as is, but the bridge continues to appear and then fade out over and over after someone has initialized it by walking on it (whether they're still on it or not) Oh yeah. Fixed above. I just forgot to change one of the target states when I copied and pasted. Sorry. That SHOULD fix it I think.
|
|
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
|
08-21-2008 22:42
thanks everybody  thank to your help i resolved my problem 
|