Door Object
by Joshua Jewell · 11/21/2006 (4:49 pm) · 25 comments
Download Code File
In order to add Door functionality into your game perform the following tasks.
=============================================
Add the following files into the engine/game/ directory
stopWatch.h
stopWatch.cc
door.h
door.cc
Now add these files into your projects workspace and compile.
=============================================
Add the following directory into the starter.fps/data/shapes/ directory
door
=============================================
Add the following script file into the starter.fps/server/scripts/ directory
Door.cs
Then add this line of code in starter.fps/server/scripts/game.cs inside the onServerCreated function:
exec("./door.cs");
=============================================
In order to add the door into the mission you will need to edit the mission file with a text editor. Here is an example of how to add a door:
new Door()
{
position = "204.274 133.53 227.3";
rotation = "0 0 -1 90";
scale = "1 1 1";
dataBlock = "Door1";
};
=============================================
Notes
A door must be modeled a certain way in order for it to rotate properly. The main thing to note is that the door rotates around the transformation. Inside the zip file is an illustration of how the doors behavior will affects the dts shape.
Running into a door that stops because it is obstructed may produce a slight bouncy effect. This is due to the fact that the server and client do not transmit the transformation on each tick. This may be changed if serious de-synchronization occurs as a result.
I am not quite satisfied with the way a door detects that it is obstructed. Right now it checks a big box to see if any player enters it. In the future (Once I figure it out) I will have it so that the door only checks the area that it exists in.
The door's transformation cannot be changed while it is opening or closing. Once it is in a closed or open state it can be moved. The new transformation will be used when it starts to close/open again.
If I missed anything please bear with me as this is my first resource. I will try to fix any errors as quickly as possible as well as clear up any questions people may have.
*In order to make the door open and close call the script method toggle(). This method will have no effect if the door is not in a closed or open state. Here is an example of the script code:
%obj.toggle;
In order to add Door functionality into your game perform the following tasks.
=============================================
Add the following files into the engine/game/ directory
stopWatch.h
stopWatch.cc
door.h
door.cc
Now add these files into your projects workspace and compile.
=============================================
Add the following directory into the starter.fps/data/shapes/ directory
door
=============================================
Add the following script file into the starter.fps/server/scripts/ directory
Door.cs
Then add this line of code in starter.fps/server/scripts/game.cs inside the onServerCreated function:
exec("./door.cs");
=============================================
In order to add the door into the mission you will need to edit the mission file with a text editor. Here is an example of how to add a door:
new Door()
{
position = "204.274 133.53 227.3";
rotation = "0 0 -1 90";
scale = "1 1 1";
dataBlock = "Door1";
};
=============================================
Notes
A door must be modeled a certain way in order for it to rotate properly. The main thing to note is that the door rotates around the transformation. Inside the zip file is an illustration of how the doors behavior will affects the dts shape.
Running into a door that stops because it is obstructed may produce a slight bouncy effect. This is due to the fact that the server and client do not transmit the transformation on each tick. This may be changed if serious de-synchronization occurs as a result.
I am not quite satisfied with the way a door detects that it is obstructed. Right now it checks a big box to see if any player enters it. In the future (Once I figure it out) I will have it so that the door only checks the area that it exists in.
The door's transformation cannot be changed while it is opening or closing. Once it is in a closed or open state it can be moved. The new transformation will be used when it starts to close/open again.
If I missed anything please bear with me as this is my first resource. I will try to fix any errors as quickly as possible as well as clear up any questions people may have.
*In order to make the door open and close call the script method toggle(). This method will have no effect if the door is not in a closed or open state. Here is an example of the script code:
%obj.toggle;
#22
Any suggestions on how the avoid this (automatic reversal if someone is standing uner it)?
07/30/2007 (1:53 pm)
I now have the door opening by a keypress when standing close by, and it will close automatically after a little while. But if I stand under it, when it closes, I get trapped in the door.Any suggestions on how the avoid this (automatic reversal if someone is standing uner it)?
#23
10/22/2007 (6:33 am)
Has anyone improved the obstruct test?
#24
Problem still on the client, the door on the server side opens but the visual of the door on the client does not move. Anyone able to look at this ?
06/07/2008 (12:59 pm)
Need to visit this again, I changed the type as suggested by Stefan and it works ok on the server side.Problem still on the client, the door on the server side opens but the visual of the door on the client does not move. Anyone able to look at this ?
#25
05/19/2013 (9:57 am)
Has anyone added this to T4D 1,2,3 ? I get all kinds of linker errors on a debug build.
Randell Ramirez