Jump to content
  • 0

Scripting a one-way prim


Yewsurname
 Share

You are about to reply to a thread that has been inactive for 1380 days.

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

Question

I remember a while back seeing someone selling a prim that you could walk through one side, but on the other side it was solid. I've gotten a bit of the scripting down but don't know where to go from here:

default
{
    state_entry()
    {
        llVolumeDetect(TRUE);
        rotation rot = llGetRot();
        float x = rot.x;
        float y = rot.y;
        float z = rot.z;
        float s = rot.s;
    }
    collision_start(integer total_number)
    {
        if(llDetectedVel(total_number))    {
            llPushObject(llDetectedKey(0), <10,0,0>, <10,0,0>, TRUE);    }
        if(llDetectedVel(total_number))    {
            llSetStatus(STATUS_PHANTOM, TRUE);  }
    }
}

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I'm not sure what your plan was for the script you started, so I can't offer much help to tell you what to do next with it.  If I were writing a script for this purpose, though, I would start over again, using either one of two approaches.  Either one would begin by sensing the direction that you were approaching the wall from.  That's just a matter of determining your local offset relative to the wall's position (that is, your offset corrected for the wall's rotation). 

Then, one approach might be to simply switch llSetStatus (STATUS_PHANTOM) from TRUE to FALSE, depending on which direction you were approaching from.  That approach is likely to be unreliable, because it depends on the servers changing the wall's status quickly, but it's worth a try.  The other approach would be to make the wall phantom all the time, but script it to repel anyone approaching from the "wrong" side.  You'd use llPushObject to do that, and you'd need to make the magnitude of the push equal to the avatar's velocity but give the push the opposite sign so that the avatar "bounces" off the wall.  I can think of two limitations to that approach: (1) your object needs to be in a push-enabled region and (2) avatars or objects approaching at more than walking speed are still likely to penetrate the wall (probably all the way through) before the servers detect that they have hit the wall. 

I remember trying variations on both of those approaches a few years ago, with unsatisfying results.  It's worth experimenting with now, though, because a one-way wall is a fun concept.

BTW, if you are scripting in an Experience or if you are scripting a wall just for your own personal amusement, you could fake the whole thing by making your wall a one-way teleporter (using llTeleportAgent ) that teleports you a couple of meters to the other side of the wall if you approach it from the correct side.  I've done that many times, and it's quite effective under those limited conditions.

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1380 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...