Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee

Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tutorial] Use crowbar to open a door
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
[Tutorial] Use crowbar to open a door

Hello everyone! Because alot of people has been asking how to open a door with a crowbar and get all the flashy effects of pulling and particles etc, here is a tutorial on how to do it! Smile

Important thing: All the items and things name can be changed they don't need to be named the same as I have in this tutorial but if you change the name remember to change inside the script!

Step 1: Choose the door of your liking on which you will use the crowbar, Then create the following so it looks like this:

[Image: 2011cz.png]

The AreaUseCrowbar is the tall script area, and should be placed in the aligned with the doors side.

The AreaBreakEffect is the little box placed near the handle of the door, you can place it a bit to the left of the handle and it should look good
It is used to make a dust effect when the door is unlocked

The BreakDoor script area is the big square on the right, It is there because when the crowbar hits the area it calls the function which opens the door.

The Crowbar_joint should be placed where the area is on the AreaUseCrowbar and should be sized up to 1.2, 1.2, 1.2. You can test how far in you want to crowbar to be Smile

The crowbar_dyn should be placed a bit to the right of the crowbar_joint and should be placed so the head of the crowbar is a little bit inside the BreakDoor area. And it should also be sized to 1.2, 1.2, 1.2
And is activated when the crowbar_joint hits the BreakDoor area and if you want the crowbar to break change the Entity file of the crowbar_dyn to Crowbar_broken

Remember: Make the crowbars inactive in the level editor

Step 2: And when all that is done it is time for the script. This is almost the same script (I removed some unecessary stuff) that Frictional games uses in Amnesia: TDD

PHP Code: (Select All)
// Run first time starting map
void OnStart()
//Makes it able for the Crowbar_joint to collide with the area in my case I call it BreakDoor

//Makes it able for the item crowbar to be used in the world, this one calls the callback if you place the crowbar on the door

//Same as above but this one creates the callback if you place the crowbar in the area in my case the AreaUseCrowbar. 
//Remember that they call the same function so it doesn't matter where you use your crowbar


//The function called from the AddUseItemCallback
void UseCrowbarOnDoor(string &in asItemstring &in asEntity)
//Calls a timer that places the crowbar in the door frame.

//Plays a sound of the player crouching. 

//Removes the Crowbar.

//The timer we called before
void TimerAttachCrowbar(string &in asTimer)
//Plays the sound of the player putting the crowbar in the doorframe

//Sets the crowbar_joint active

//The function we called from the AddEntityCollideCallback
void CollideAreaBreakDoor(string &in asParentstring &in asChildint alState)
//Gives a small boost of sanity

//Plays music because you completed the puzzle

//Unlocks the door

//Makes the door not auto close on itself

//Opens the door slightly

//Plays the sound of wood breaking.

//Creates a small dust smoke

//Adds a impulse on the door. This may need some adjusting since your door may be facing another direction than mine

//Sets your crowbar_joint inactive

//Sets your dynamic crowbar active, In this case it's the Broken crowbar that will fall to the ground.
//You can use the crowbar_dyn then it will fall to the ground without being broken

//Creates a timer that will make the door open slightly

//A debug showing that the door is open
AddDebugMessage("Break door!"false); 

//A timer that is going to push the door open
void TimerPushDoor(string &in asTimer)
//Adds a impulse on the door so it opens. Needs to be adjusted according to where your door is facing
AddPropImpulse("NAMEOFYOURDOOR", -12, -4"world");

//Creates a Timer so the door can auto close again.
//Timer we just called
void TimerDoorCanClose(string &in asTimer)
//Makes the door able to auto close.


If I missed something please let me know and I fix it ^^

I will maybe do a video tutorial on this if you guys want Smile

Almost forgot!

Here's a map + code for download, so you can look and see how it works yourself

(This post was last modified: 05-15-2012, 03:03 PM by SilentStriker.)
02-01-2012, 04:04 PM
Find Reply

Messages In This Thread
[Tutorial] Use crowbar to open a door - by SilentStriker - 02-01-2012, 04:04 PM

Users browsing this thread: 2 Guest(s)