Door with script


#1

I want to share a door with an open/close script.
The model can be downloaded from here:

http://transmissiongate.com/door.fbx

After you imported the door, you must copy their ID.

In order to make it work, you need to create a box that overlap the door in both sides.
Make this box collissionless and invisible.
Scale this box until it touch the floor and rise upon your avatar head.
Place on this box the flowing script:

(function () {
	 var doorID = '{your-door-entyty-ID-here}';
	 var animationSettings = {
       url: "atp:/door.fbx",
       running: true,
       fps: 30,
       firstFrame: 61,
       lastFrame: 150,
       loop: false
    }
	var animationSettings1 = {
       url: "atp:/door.fbx",
       running: true,
       fps: 30,
       firstFrame: 0,
       lastFrame: 60,
       loop: false
    }

this.enterEntity = function (entityID) {
        print("open");
        Entities.editEntity(doorID,  {animation: animationSettings1});
        Entities.editEntity(doorID,  {collisionless: true});
    };

this.leaveEntity = function (entityID) {
        print("close");
        Entities.editEntity(doorID,  {animation: animationSettings});
        Entities.editEntity(doorID,  {collisionless: false});
    };
 })

You must replace in this script ‘{your-door-entyty-ID-here}’ with your door ID.

TIP: If you do not know how to do this, it’s very simple:
Open a notepad editor insert this code into it, save the file as door.js
Upload this script to the domain asset server
Place address atp:/door.js in the previously created box in the ScriptURL field.

Knock, Knock! :slight_smile:


#2

That looks more reliable then my door from 2 years ago.
We did not have animation like this.

Interesting to test.


#3

I may be wrong, last time I checked animations are not physical, so you can walk through the door even if its closed, has this changed?


#4

Unfortunately not. I still try to find a way.


#5

I have made doors with the physics hinge action, although the hinge action isn’t fully implimented
so it takes some work. i.e. to get it to close you put the hinge next to another object so the door closes by trying not to be inside the other object. When the hinge is complete there will be more settings that can close the door ect. more naturally.


#6

For the moment, we can do the trick with collisionless property.
In this case of automatic open/close script isn’t necessary. If you want to change the script in order to act as a door and open based on password, you can set the collisionless parameter true or false from the script.


#7

I need to check my old door on marketplace and see if it’s still complete and put it back n marketplace. Just others can compare.


#8

Updated Door script with password

I want to share an advanced door script, that open the door based on numeric password.

You must download and unpack this archive

http://transmissiongate.com/door-code.zip

The archive contain following files:

the door model: door.fbx
the case of security number pad:case.fbx
keys: k0.fbx ... k9.fbx, ks.fbx and kd.fbx
scripts: k0.js ... k9.js, ks.js and kd.js

Import the fbx files on your asset server and place the fbx files in your scene.

Copy the door ID from your scene and edit door.js and kd.js and place the ID value
In kd.js you can choose your own code to open the door. Must be in the following format:
character k followed by any numeric combination with unlimited number of characters.
for example: k0789134523

Import your scripts on your asset server and place on each numeric keypad button the correspondent script
for example on k0.fbx button place on scriptURL: atp:/k0.js … on ks.fbx place ks.js

Create a box that is placed behind the door, that is scaled from the floor to the avatar head,
the box must intersect the center of the door. Make this box colissionless and hidden.
Place on this box on scriptURL: atp:/door.js

This box is needed to trigger the open action from the inside.

To use the numeric pad to open the door:
push on the keypad * key, followed by your secret number and # key


#9

Updated Door script

I’ve updated the script in order to have animated buttons on mouse click/release.
The instructions are the same, but you need to edit also the k0.js… ks.js and change correspondent ID of the imported buttons.
the archive can be downloaded from:

http://transmissiongate.com/newdoor.zip