Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting if an object is on a surface

Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
08-21-2007 09:27
Hullo all, I'm making a vehicle that will go into different modes depending on whether it's airborne, in the water or flying. Detecting water and ground is easy enough, thanks to llWater and llGround.

But how do I detect if the vehicle has landed on (for example) a skyplat or other flat, non-ground surface?
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
08-21-2007 09:56
It's not as easy, but use the collision_start event, and use the llDetectedType() and llDetectedPos() functions to determine a) that it actually is a prim surface (ACTIVE | PASSIVE), and b) that it actually is underneath.
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
08-22-2007 09:12
Hmmmm......so something like:
CODE

integer airborne=TRUE;

default
{
collision_start(integer num_detected)
{
vector pos = llGetPos() - <0,0,1.0>;//put an offset in for the aircraft gear length
if (pos.z > llDetectedPos())
{
if (llDetectedType(0) ~ AGENT)
{
airborne=FALSE;
}
}
}
}



One thing I'm really sure I've got wrong is the detected type line. Basically, I don't want it to land on an avatar. The wiki says llDetectedType returns a bitfield, so you have to use bitwise operators, something I'm really not good at. How should I write that if statement so it returns true if the detected type is anything but an agent?
Eyana Yohkoh
Registered User
Join date: 30 Nov 2006
Posts: 33
08-22-2007 14:14
I think llDetectedType comparisons need to be an AND check, like:

if ( llDetectedType(0) & AGENT )

So that doesn't solve your problem really. I would try something like this:

default
{
collision_start(integer collided_number)
{
integer agentCheck = llDetectedType(0) & AGENT;
if ( !agentCheck)
{
llSay(0, "Raar!";);
}
}
}


I'm not really sure that would work either and since SL is still offline I can't double check it right now.
_____________________
http://eyanayohkoh.blogspot.com
http://www.lslwiki.net/lslwiki/wakka.php?wakka=EyanaYohkoh
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
08-23-2007 09:12
Worked perfectly, thanks!
Eyana Yohkoh
Registered User
Join date: 30 Nov 2006
Posts: 33
08-23-2007 12:26
You're quite welcome!
_____________________
http://eyanayohkoh.blogspot.com
http://www.lslwiki.net/lslwiki/wakka.php?wakka=EyanaYohkoh