Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Water Event/Collision Detection

SiRiS Asturias
Chaotic Coder
Join date: 27 Sep 2005
Posts: 93
12-06-2005 02:08
A workaround recently used to detect water & start a splash particle system for plane pontoons on landing:
CODE
// Script created by SiRiS Asturias.
// All rights reserved. (c)2005 (Released as OpenSource 12/06/2005)
// Free for use as long as this header stays intact & follows the below guidelines.

// This work is licensed under the:
// Creative Commons Attribution-NonCommercial-ShareAlike License.
// To view the full copy of this license, please visit:
// http://creativecommons.org/licenses/by-nc-sa/2.0/

integer a;// Idle switch
default
{
state_entry()
{
llSetHoverHeight(0.15,TRUE, 0.5);// Make plane hover
llSetTimerEvent(0.2);//Land Timer
}
timer()
{
vector pos =llGetPos() -<0,0,0.2>;//Cuurent position minus offset
float water =llWater(<0,0,0>);// Water height in the current Sim
if (a == 1)// If idle
{
if (pos.z> water)// Check to see if we are off the water
{
llOwnerSay("In the air");
llSetTimerEvent(0.2);//Took off, start landing timer again
a = 0;//Set state back to airborne
}
}
else if (pos.z <= water)// Landed on water, trigger particles and wait to leave
{
llOwnerSay("Water Landing");
Water(); // Start splash particle system
llSetTimerEvent(5.0);// Idle grounded timer
a = 1;//Set state to water landing
}
}
}
This way the only thing it does each timer event is a water to current height comparison on the Z vector.
Could easily be modded to add only calling the llWater function per Sim change for even more efficiency per timer event.
Enjoy!:D
_____________________
Proud founder of:
S3 - Self Storage Systems
S3storage.net (Coming Soon!)

SLBoutique.com
SLExchange.com - Find What You Need, When You Need It.

"Light travels faster than sound. This is why some people appear bright, until you hear them speak."
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
original Thread
12-06-2005 22:19
/15/70/75724/1.html
_____________________
i've got nothing. ;)