Forum Archive

Go Back   3D Realms Forums > 3D Realms Topics > Other Apogee/3D Realms Games > Prey
Blogs FAQ Members List Social Groups Calendar Mark Forums Read

Notices

 
 
Thread Tools
Old 07-27-2006, 02:19 PM   #1
Luke

Luke's Avatar
Rotating Door Tutorial


So you have fired up Preditor and had a deep look at its ugly inards. Perhaps you have created a few test maps with a few things here and there with the odd light and door, but now you want to do something a little more complicated. You want to create a map where the doors do not just slide to the side but react like everyday doors opening at an angle outwards. Fear not for here I have the means to create this legendary 'rotating' door.

This tutorial will require the following programs:
Preditor – Prey Map Editor
Notepad – Script Writing

Ok the first step in this tutorial is to define, within your map, the brush that is going to be the rotating door. Simply select the brush, press N to go to the entities menu and from the drop down menu select ‘func_mover’ and then click create. The brush wireframe will now have changed colour to indicate that it has become an entity. You may also note that a red dot has appeared. This will serve as the point or 'origin' at which your brush will rotate around. You will need to rename the entity for the later script to know what entity to effect. In this case I named it ‘mydoor’. To do this type ‘name’ in the key area of the entity properties and then type ‘mydoor’ in the val section and press enter. As you can see below you will want this to be on the corner for it to simulate a rotating door effect.

Once you have done this save the map. In this instance I saved the map as test.map. Now comes the scripting part. Do not be put off it is an extremely simple script that I will explain fully so that you may edit it to your heart’s content.

Open up notepad and enter the following:


Code:
void rotate_door ()

{
$mydoor.time(0.5); 
$mydoor.rotateTo('0 80 0');
sys.wait(3);
$mydoor.rotateTo('0 0 0');
}
The ‘mydoor’ text is a reference to the name of the entity within the map. This is why earlier I named the func_mover ‘mydoor’ so that this script would know which entity to affect. The numbers within the brackets after rotateTo are angles in degrees, around the X Y Z axes. The 80 in this case commands the mover to rotate 80 degrees on the Y axis and then later the 0 commands it to return to its previous state.

Once all of this is done save the script in the same folder as your map and as the same name as your map, in this case ‘test.script’. This is because we only want this script affecting this particular map. Now that this is done we need to go back into Preditor.

Back in Preditor we can add the final step. We need to set up a trigger, and invisible force that when set off will initiate the rotate_door script and open our door. Ok now draw a brush the same height and width of the door only a lot deeper and place it over the door so that the door is visible within it. Now that this is done, same process as before, hit N to bring up the entities menu and set this entity as a ‘trigger_multiple’. When you have done this we need to make sure that this trigger runs the script so first of all we need to connect the trigger and the door. First select the trigger then shift select the door so they are both selected. Hit Ctrl + K and a line with an arrow should appear indicating the entities are now connected. The next step is to go back into the triggers entities properties so select it and hit N. Repeat what you did before to give the door its name only this time for Key type ‘Call’ and for Val type ‘rotate_door’ and hit enter. The call function makes the trigger initiate the rotate_door script and as the trigger is connected to the door entity, the script controls the door to open. Simple no? Now to clean it up add the Key ‘Wait’ and Val ‘3’ and hit enter. This will make the trigger wait 3 seconds before being able to be used after being triggered which stops the door flying open and shut wildly.



Now you are done. Simply add a player start, some light and all that jazz and get in the game and you will have a fully functioning rotating door.

The Map from the screen along with the script and textures can be downloaded here in a pk4, map name ‘test’.

Tell me what you think this is my first tutorial .
__________________
Original Blackhole / Dark Portal theorist.
Last edited by Luke; 07-27-2006 at 02:46 PM.
Luke is offline  
Old 07-27-2006, 02:50 PM   #2
Otto

Otto's Avatar
Re: Rotating Door Tutorial
Cool. Nice graphic. Thanks for the screenshots and code. I'll try to check this out later tonight.
Otto is offline  
Old 07-27-2006, 02:56 PM   #3
Luke

Luke's Avatar
Re: Rotating Door Tutorial
Exellent. Please contact me on geach59@hotmail.com MSN if you need any help. I will also be in the Preditor IRC channel.
__________________
Original Blackhole / Dark Portal theorist.
Luke is offline  
Old 07-28-2006, 02:24 PM   #4
Shrinker
Re: Rotating Door Tutorial
I improved the map a bit and the script a lot, now you can even copy/paste that door+triggers, and it opens in both directions!
http://www.intercomm.com/shrinker/do...eydoortest.rar
Shrinker is offline  
Old 08-28-2006, 02:33 PM   #5
Altered Reality

Altered Reality's Avatar
Re: Rotating Door Tutorial
I modified the script to make the door rotate clockwise when it opens:
Code:
void rotate_door()
{
 $mydoor.time(0.5); 
 $mydoor.rotateTo('0 -80 0');
 sys.wait(3);
 $mydoor.rotateTo('0 0 0');
}
But I have a problem. When the door closes, it STILL rotates clockwise! It actually rotates 280 degrees to return to its initial position!
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve)
I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll)
Faith is why you are wrong. (Crosma)
Altered Reality is offline  
Old 08-28-2006, 02:46 PM   #6
Luke

Luke's Avatar
Re: Rotating Door Tutorial
Quote:
Originally Posted by Altered Reality View Post
I modified the script to make the door rotate clockwise when it opens:
Code:
void rotate_door()
{
 $mydoor.time(0.5); 
 $mydoor.rotateTo('0 -80 0');
 sys.wait(3);
 $mydoor.rotateTo('0 0 0');
}
But I have a problem. When the door closes, it STILL rotates clockwise! It actually rotates 280 degrees to return to its initial position!
Thats why i didn't do that. All you have to do is change the center of rotation in Preditor.
__________________
Original Blackhole / Dark Portal theorist.
Luke is offline  
Old 08-28-2006, 02:47 PM   #7
Altered Reality

Altered Reality's Avatar
Re: Rotating Door Tutorial

So, how do I make the door rotate clockwise? And generally speaking, how do I decide the rotation direction?
Quote:
All you have to do is change the center of rotation in Preditor.
But the center of rotation is where I want it to be... the direction is what I want to change!
In other words, if the door was real, now I'd have to pull it open. Without moving the hinges, I want to PUSH it open instead.
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve)
I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll)
Faith is why you are wrong. (Crosma)
Last edited by Altered Reality; 08-28-2006 at 02:53 PM.
Altered Reality is offline  
Old 08-28-2006, 03:03 PM   #8
Luke

Luke's Avatar
Re: Rotating Door Tutorial
simple... rotate the entire door then re apply the centre.
__________________
Original Blackhole / Dark Portal theorist.
Luke is offline  
Old 08-28-2006, 05:18 PM   #9
Interitus

Interitus's Avatar
Re: Rotating Door Tutorial
.rotateTo always seems to rotate in the clockwise direction, and I'm unsure how to change it, maybe check doom_events.script.

But I would suggest using .rotateOnce(' X Y Z '); instead, 90 will rotate 90 degrees clockwise, -90 will rotate 90 degrees counter-clockwise. While .rotateTo() you're specifying the angle you want to rotate to.
__________________
Nahallan.com
If you ever think you've hit rock bottom, get the f*** off my shoulders.
"Indeed, I am so far OUT of sane that you appear a tiny blip on the distant coast of sanity" - Bucky Katt
Interitus is offline  
Old 08-28-2006, 05:55 PM   #10
prey fan

prey fan's Avatar
Re: Rotating Door Tutorial
ok witch file do i put this in?
prey fan is offline  
Old 08-29-2006, 02:34 PM   #11
Altered Reality

Altered Reality's Avatar
Re: Rotating Door Tutorial
Quote:
But I would suggest using .rotateOnce(' X Y Z '); instead
Thanks. That did it.
Quote:
ok witch file do i put this in?
If (for example) your map is called myfirstmap.map, you must save it inside a file called myfirstmap.script.
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve)
I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll)
Faith is why you are wrong. (Crosma)
Altered Reality is offline  
Old 08-29-2006, 07:00 PM   #12
prey fan

prey fan's Avatar
Re: Rotating Door Tutorial
in what the prey file?
prey fan is offline  
Old 08-30-2006, 02:36 PM   #13
Altered Reality

Altered Reality's Avatar
Re: Rotating Door Tutorial
Quote:
Originally Posted by prey fan View Post
in what the prey file?
Assuming you mean "Where do I put the script file?": in the same directory where you have your map.
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve)
I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll)
Faith is why you are wrong. (Crosma)
Altered Reality is offline  
Old 10-22-2006, 02:36 AM   #14
Altered Reality

Altered Reality's Avatar
Re: Rotating Door Tutorial
I thought I'd post in this topic since my question is about doors.
How do you make a rotating door that you actually have to USE (meaning Tommy will extend his hand toward it, and you'll have to click the left mouse button to open the door)?
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve)
I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll)
Faith is why you are wrong. (Crosma)
Altered Reality is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:12 PM.

Page generated in 0.15025306 seconds (100.00% PHP - 0% MySQL) with 15 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.

Website is 1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.