Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

collision problems

Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
10-18-2009 16:42
Hey!

I'm trying to make a floor that will set an texture on another prim as long as there is someone on the floor.

I'm trying with this:

Floor:

default
{
collision(integer num_detected)
{
llSleep(2.0);
if (llDetectedType(0) & AGENT)
{
llSay(35, llDetectedName(0));
}
}
collision_end(integer num_detected)
{
llSleep(2.0);
if (llDetectedType(0) & AGENT)
{
llSay(35, "Default_Texture";);
}
}
}

Texture prim:

default
{
state_entry()
{
llSetTexture("Default_Texture", 0);
llListen(35, "stage", NULL_KEY, "";);
llListen(45, "", llGetOwner(), "";);
}

listen(integer channel, string name, key id, string message)
{
if (channel == 35)
{
llSetTexture(message, 0);
}
if (channel == 45)
{
llSetTexture(message, 0);
}
}
}

It works.. somewhat.

In the texture prim, I have a texture named as my avatar name.
So when I am standing on the floor, it shows the picture, for a few seconds. Then it reverts back to the Default_Texture.
I suppose that the script comes to collision_end when I am not moving.
I'l looking for suggestions on how to get around this, I don't want to have the Default_Texture set untill I completely leave the floor.
Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
10-18-2009 17:06
Any reason why you can't use llSensorRepeat to detect the avatar standing in the room instead?
XArd Zond
Registered User
Join date: 10 Jun 2009
Posts: 7
10-18-2009 17:12
You could try using llVolumeDetect() I guess.

Set the agent detecting floor to phantom with another floor underneath to stand on.

default
{
state_entry()
{
llVolumeDetect(TRUE);
}
collision_start(integer num_det)
{
//On the floor
}
collosion_end(integer num_det)
{
//Off the floor
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-18-2009 17:17
Sensor Repeat is a lot more laggy, especially if you have to repeat as frequently as I think the OP does. It could also be a bear if the goal is to distinguish between being on the floor and being next to the floor (as in, sitting at a table next to the dance floor). You'd have to be nitpicky careful to get the scan range just right for SensorRepeat to work well.

Unfortunately, collision_start and collision_end bounce, so you get false collisions a lot. Using llVolumeDetect helps some, but I still get extra hits if I walk around on a prim scripted to detect collisions. I'd like to know a reliable answer to the OP's question myself.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
10-18-2009 17:24
Kayaker:
Nopes.. I just didn't know about it. Not that good of a scripter.
Thing is, there well be a lot of avatars in the room, but (in this case), only my picture will be in the textureprim. So I have to (first) work it out to be stable and not to stop seeing me standing on the floor.
Next up, I will need to have to use some if's and else's to work out if the avatar who is standing on the floor also has a pic in the textureprim and a lot of other yadda yadda. But I have to start somewhere. :)

I'll check that out, thanks. :)

Thanks XArd, I'll try it. :)

Rolig:
Yeah, it will need to scan pretty often, and preferably not take into account people who are very close to the floor.
Allthough, I might have to work a bit with sensors too, since an avatar could also sit on a chair on the floor, that has to be detected too. I guess collisions won't work there.
(I just came to think of it while writing)
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-19-2009 00:37
hmmm...

I would use llVolumeDetect() just to collect AV keys in the collision_start() event. You just put them in a list if they aren't already in.

Then you use llGetObjectDetails() to check their positions in a timer. So it wouldn't matter if they are actually standing on the floor, sitting or hovering. If they are within the volume you decide to consider as "over the floor", you increment a counter. At the end of the loop the counter will contain 0 for nobody or anything else for somebody.

In the loop, you also check if the position of the AV is ZERO_VECTOR (The AV left the sim) or too far from the floor prim with llVecDist(). You just remove the key in both cases and the list will remain under control.

Very simple.