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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Self Opening/Closing Doors
Carlos2295 Offline
Junior Member

Posts: 16
Threads: 5
Joined: Sep 2014
Reputation: 0
#1
Self Opening/Closing Doors

Hi there, sorry for asking so many questions, but I really need to lol. Anyways, what I'm trying to do is make a door that will open upon entering a scripting area. Also, I was hoping to make another door that would close upon entering the room. Here's what I have so far for my script. However, it doesn't seem to work. I have the door open amount set to 1.

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""dooropen""DoorFunction"true1); 
}
void OnEnter()
{
    
PlayMusic("06_amb"true0.91.01true);
}
void DoorFunction(string &in asParentstring &in asChildint alState)
{
    
SetMoveObjectStateExt("castle_1"051010false);
    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0false);
    
PlaySoundAtEntity("""react_scare""Player"0false);
    
PlaySoundAtEntity("""close_door.snt""Player"0false);
    
GiveSanityDamage(5.0ftrue);

[/php]
10-02-2014, 02:32 AM
Website Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Self Opening/Closing Doors

This may help.

(06-13-2012, 01:39 PM)GrAVit Wrote: There are multiple ways of doing that, but probably the most convinient one would be to use the Area tool in the level editor. Place an area near the door where you would want the script to active, which would make the door open itself.
Then you need to add the script, first you need to add a callback function like this for example:
void OnStart()
{
AddEntityCollideCallback("Player","THEAREANAMEYOUCREATEDINLEVELEDITOR","YOURFUNCTIONNAME",true,1);
}
YOURFUNCTIONNAME is the function that will be called when you enter the area. You can name it whatever you want.
Then the function, this is an example, it works if the door is unlocked.
void YOURFUNCTIONNAME(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorDisableAutoClose("YOURDOORNAMEHERE", true);
AddPropForce("YOURDOORNAMEHERE",x,y,z,"world");
}
The x,y,z here means which way the propforce is coming from, which will force the door open. So you will replace x,y,z, with numbers, example: 0,0,-4000, You also need to add a considerable amount of propforce in order to open it, for example, 4000 or 5000. The negative amount here does not matter since it only describes which way the force is coming from. I hope this helped.
You may also add a sound effect when the door slams, and a particle effect as well.

Try reading through that, and if you don't understand something, just point it out and I'll let you know Big Grin

With the closing door though, there's a pretty simple code for that:

PHP Code: (Select All)
SetSwingDoorClosed("door_name"truetrue); 

And that would go within the callback code (so where the (string &in asParent, string &in asChild...) goes), changing "door_name" to the name of your door, keeping the quotes!

Discord: Romulator#0001
[Image: 3f6f01a904.png]
10-02-2014, 03:39 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Self Opening/Closing Doors

I made a video tutorial on this exact topic. Perhaps it will help you if you prefer going a bit slower through it.



10-02-2014, 09:47 AM
Find




Users browsing this thread: 2 Guest(s)