This site is in no way affiliated with or endorsed by Linden Labs

Second Life® and Linden Lab® are trademarks or registered trademarks of Linden Research, Inc. All rights reserved. No infringement is intended.
Site Map
RSS Feed from slBuilding.com
 
Make a gift of hope for someone with HIV / AIDS
This tutorial walks you through how to create a door that opens and closes when you touch it, a fairly simple and common requirement that can be difficult to achieve.

Note that to do any building in Second Life you either need a premium account and buy some land, or have access to a sandbox. A sandbox is an area of Second Life where you can build objects without having to own any land. You can find sandboxes by searching for "sandbox" in the Places search in Second Life
(but make sure they allow you to run scripts, not all do).

Creating a door than opens/closes when touched - Full Video Tutorial
I hope you enjoy watching the video.
Copyright © 2007 Ian Monstre  ·  All Rights reserved

Full Video
Two obstacles need to be overcome when you're creating a door that opens and closes when touched:






We cover both of these issues in the video.

Download/Stream  Running time: 6 minutes 41 seconds
Download source code used in video

Download source code for alternative rotation method

1. Working out how to "hinge" the door along one edge instead of in the middle
2. Working out the angle to rotate the door to when it is open
Note: The technique shown in the video is a pretty simple approach that focuses on getting the job done rather than "elegance" in terms of the script used. You could certainly use a slicker approach eg by using the llEuler2Rot and llRot2Euler functions as described here. In fact, I've written a sample script that you could use instead of the one in the video.

Also be aware that you can sometimes run into problems with rounding when doing direct comparisons with float values in your script. So you may find for example that when you're comparing the "x" value of your rotation variable with a value (eg 'if (rot.x == 0.123456)') it doesn't seem to work. The reason for this is that LSL is rounding or truncating the value when it displays it on the screen. The way around it is to convert the float to a string and use that when comparing. For example, you would use 'if ((string)rot.x == "0.123456")' instead.

If you're confused :-) feel free to drop me a line. However bear in mind that all of the above is only really worth bothing with if you're having problems - otherwise you can ignore it.