Swing door that opens on walking into it
From The Schommunity Wiki
This is a swing door that opens when you walk into it. Put this in a small prim that acts as a hinge, then link a door pannel to it. This has to be in the ROOT PRIM.
//17/1/9
//swing_door_collision_right_v1.0 olly butters
//Put this in a hinge and link the door to it.
//walking into the door will open it.
float opening_angle = 90; //opening angle surprisingly
default
{
state_entry()
{
state closed;
}
}
//this is when the door is closed. touching it will open the door and change to open state.
state closed
{
state_entry()
{
}
collision_start(integer num_detected)
{
rotation dave = llEuler2Rot(<0.0,0.0,opening_angle*DEG_TO_RAD>);
llSetRot(dave);
state open;
}
}
//this is when the door is open, it will sleep then close the door then move back to the closed state.
state open
{
state_entry()
{
llSleep(5);
rotation dave = llEuler2Rot(<0.0,0.0,0.0>);
llSetRot(dave);
state closed;
}
}