Jump to content
You are about to reply to a thread that has been inactive for 665 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi All,

On my latest project I want to detect when an Av passes through a doorway, and know from which side of the doorway they have 'entered'. Basically want to know if they have entered or left the space (an Elevator). While I realise that if they manage to TP in, or they TP out there is more to do, but for now just working on simple movement.

So to do this I'll have a transparent, thin prim, with llVolumeDetect set. From reading through the wiki  my conclusion is I'll need to use the collision_start event, and then using llDetectedPos check the result against the detector prim's position to calculate which side they hit, correct? Or is there a way to see which face they collided with that I am missing?

Thanks!

Wanda

Link to post
Share on other sites

hmmm .. just thought of a solution .. I think ... please correct me if I am mistaken:

Make the detector prim the same size as the elevator. Then collision_start is triggered when they enter, and collision_end when they leave. This as well, from what I have read, would trigger if they TP'd in or out .. no? If so then the only question is .. would the events trigger if the logged out/in from inside the elevator (detector prim)?

Edited by Wandering Soulstar
spelling
Link to post
Share on other sites

Your first method is right on track, it'll take a tiny bit of math because there is no (well, maybe one) way to detect which face was collided with.

The second method would also work fine for one person. What if someone is already in the elevator and another walks in with them? It's not impossible to work around, just something to keep track of.

The one possible way for face detection I mentioned is with llCastRay. Essentially, you instantly draw a line from A to B and see what the line collided with. You can find out which way the prim's face is... facing... but you'd still need to do the same "directional math" as with an avatar collision. I don't recommend doing this as a practical solution.

Edited by Wulfie Reanimator
Link to post
Share on other sites

@Wulfie Reanimator

Thanks, as I suspected. Your comment on the second method though has me confused. Even if one AV had entered the detector prim, and was still there, would a second AV entering not also trigger the collision_start event (or _end as the case may be)?

Edited by Wandering Soulstar
spelling
Link to post
Share on other sites
6 minutes ago, Wandering Soulstar said:

@Wulfie Reanimator

Thanks, as I suspected. Your comment on the second method though has me confused. Even if on AV had entered the detector prim, and was still there, would a second AV entering not also trigger the collision_start event (or _end as the case may be)?

It would. But that is a very important detail to know, depending on what your script does on _start or _end.

If your elevator immediately reacts to either of those events, it'll likely break, depending on what it's doing and how.

Link to post
Share on other sites

Ok .. thanks .. and it actually will do very little. Just advise if there is anybody in the elevator or not .. actual movement of the elevator works another way

 

default
{
    state_entry()
    {
        llVolumeDetect(TRUE);

        //will correspond to position (up/down)
        ME = llGetObjectDesc();
        llListen(MAIN_CH, EMPTY_STR, NULL_KEY, EMPTY_STR);

        //Ask main for where we are .. if main does not reespond, not on yet
        llWhisper(MAIN_CH, F_REQ_POSITION);
    }

    listen(integer channel, string name, key id, string message)
    {
        if (channel == MAIN_CH)
        {
            //main advising where the elevator is
            list data = llParseString2List(message, [FUNC_SEP], [EMPTY_STR]);
            if (llList2String(data, 0) == F_POSITION)
            {
                gCurPosit = llList2String(data, 1);
            }
        }
    }

    collision_start(integer total_number)
    {
        //someone has come into the elevator/detector
        //advise if the elevator is actually in my position
        if (gCurPosit == ME)
        {
            llWhisper(MAIN_CH, F_ENTER + FUNC_SEP + (string)total_number);
        }
        
    }

    collision_end(integer total_number)
    {
        //someone has left the elevator/detector
        //advise if the elevator is actually in my position
        if (gCurPosit == ME)
        {
            llWhisper(MAIN_CH, F_EXIT + FUNC_SEP + (string)total_number);
        }        
        
    }
}

 

Edited by Wandering Soulstar
  • Like 1
Link to post
Share on other sites

This is how I detect if someone is entering or leaving a room, using an invisible prim with llVolumeDetect(TRUE); set. 

This assumes that the detector prim has its positive x axis facing out of the room (so you collide with face 2 on your way in and with face 4 on your way out), but it's easy to change.

    collision_start(integer num_detected) {
        rMyRot = llGetRot();
        vMyPos = llGetPos()/rMyRot;//discount the prim's local rotation
        key kCollider = llDetectedKey(0);
        vector vDetectedPos = llDetectedPos(0)/rMyRot;//discount the prim's rotation here, too, so vDetectedPos is now the same as it would be if the prim were rotated at <0,0,0>
        float f = vDetectedPos.x - vMyPos.x;
       // llOwnerSay((string)f);
        if(f>0.0){
           //entering room

        }
        else if (f<0.0){
		//leaving room
        }
    }

 

  • Like 3
Link to post
Share on other sites

Does it really matter in an elevator if the avatar teleports out?    Presumably the elevator simply continues on its way to the selected floor.   On arrival it stops and opens the door, just as it would if the avatar hadn't teleported out.

ETA:   I've always had very mixed results when trying to use collision events to track whether someone's standing on an object or not.   Sooner or later, the logic always breaks down for no readily apparent reason, particularly if the avatar moves around on the surface that's doing the detecting.     I've generally ended up using additional tests, based on the IsPointInPolygon2D function, to keep track of when avatars are, in fact, no longer standing on the surface, though I would imagine that adding avatars to a list (if they're not already on it) in the collision_start event and removing them from it in the collision_end event should work, too.

Edited by Innula Zenovka
  • Like 2
Link to post
Share on other sites

@Innula Zenovka

You are correct in that it is really immaterial to the movement of the elevator if the AV TPs out while in movement. I want to track the in/out of the elevator for actions that occur whilst the elevator is at rest. And while in movement I'd have no idea if the AV had left or not. To use the detector prim I'd need to move it along with the elevator as it cannot be linked, llVolumeDetect turns it and anything attached phantom.

Link to post
Share on other sites
5 hours ago, Wandering Soulstar said:

To use the detector prim I'd need to move it along with the elevator as it cannot be linked, llVolumeDetect turns it and anything attached phantom.

Alternatively, you might have a linked detector prim that is normally solid but, when someone collides with it, briefly turns into PRIM_PHYSICS_SHAPE_NONE (and possibly gives them a gentle shove to stop them blocking the doorway).   

  • Like 1
Link to post
Share on other sites

@animats

Thanks for the suggestion but is over the top for what I need and as well would require a lot of additional code. All I need to know is if anyone has come into the elevator or has left. Do not care about the individual, rather just the total number of passengers inside the elevator. Tracking the AV would mean keeping track of all that have entered, and considering the space inside is not extensive (it is an elevator after all) the changes in position would be minimal, with their location inside the elevator being irrelevant.

Link to post
Share on other sites
On 11/29/2018 at 6:08 AM, Wandering Soulstar said:

Make the detector prim the same size as the elevator.

On 11/30/2018 at 3:36 AM, Wandering Soulstar said:

To use the detector prim I'd need to move it along with the elevator as it cannot be linked, llVolumeDetect turns it and anything attached phantom.

Or the whole elevator shaft could be filled with one llVolumeDetect column that talks to the elevator cab object. One or the other might be scripted to check that any colliding agents are really within the elevator cab's volume -- as opposed to plunging to their death, riding the top of the cab, climbing the cables, or any other drama unfolding in this elevator shaft. 

 

 

  • Like 1
  • Haha 1
Link to post
Share on other sites
On 11/30/2018 at 6:32 AM, Innula Zenovka said:

Alternatively, you might have a linked detector prim that is normally solid but, when someone collides with it, briefly turns into PRIM_PHYSICS_SHAPE_NONE (and possibly gives them a gentle shove to stop them blocking the doorway).   

I do something like that with my escalator. There's a small invisible pusher at the end to nudge riders off the steps and onto the platform. Otherwise they can get stuck, walking in place.

  • Like 1
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 665 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...