Webber1900
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2013
Reputation:
0
|
Problem with Scripts: AddPropForce not working
Hello, I am trying to get a swing door to open slowly by itself using AddPropForce. An example of what I want is in the original Amnesia in the Rain Hall level. However for the past 2 hours I have been trying to do this but every single time I enter the script area, the door does nothing. Everything looks fine in the script but it just doesn't want to work.
Here is the entire script for the level:
//This is only executed when the map is loaded for the first time. Only happens once. Can be used for adding effects that should not repeat.//
void OnStart()
{
SetPlayerLampOil(70);
GiveItemFromFile("lantern", "lantern.ent");
AddEntityCollideCallback("Player", "Door_Creepy", "DoorOpens", true, 1);
}
void DoorOpens(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("CreepyDoor", false, false);
SetSwingDoorDisableAutoClose("CreepyDoor", true);
AddTimer("swing_door", 0.01f, "TimerDoor");
}
void TimerDoor(string &in asTimer)
{
if(asTimer == "swing_door")
{
AddPropForce("CreepyDoor", 500.0f, 0.0f, 0.0f, "world");
}
}
//This is executed every time you enter the level. Can be executed several times. Can be used for playing music and adding checks.//
void OnEnter()
{
AddEntityCollideCallback("Player", "ReturnPlayerArea_0", "ReturnPlayer", false, 1);
}
void ReturnPlayer(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer("PlayerStartArea_1");
}
//This is executed every time you leave the level. Can be executed several times. Can be used for stopping music//
void OnLeave()
{
}
I just don't know what to do and need help.
|
|
06-06-2013, 12:50 AM |
|
DeAngelo
Senior Member
Posts: 263
Threads: 26
Joined: Feb 2013
Reputation:
11
|
RE: Problem with Scripts: AddPropForce not working
I think you're not adding enough. From the wiki:
These functions push objects. Note that rather high values are needed when applying forces (on the order of ~100 (weak) to ~10000 (strong)),
Pump that number up a bit and you should see some effects.
|
|
06-06-2013, 01:12 AM |
|
Webber1900
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2013
Reputation:
0
|
RE: Problem with Scripts: AddPropForce not working
That's not the problem unfortunately, I think it's the script or the AddEntityCollideCallback...
|
|
06-06-2013, 01:36 AM |
|
DeAngelo
Senior Member
Posts: 263
Threads: 26
Joined: Feb 2013
Reputation:
11
|
RE: Problem with Scripts: AddPropForce not working
I don't think that "if astimer" part is needed. I've used tons of timers and never needed to use an if statement to get them to work.
|
|
06-06-2013, 01:48 AM |
|
Webber1900
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2013
Reputation:
0
|
RE: Problem with Scripts: AddPropForce not working
I did some changes to the script and the objects in the level editor, and seems I can now only get it to work until after I interact with the door.
Here is the modified script:
//This is only executed when the map is loaded for the first time. Only happens once. Can be used for adding effects that should not repeat.//
void OnStart()
{
SetPlayerLampOil(70);
GiveItemFromFile("lantern", "lantern.ent");
AddEntityCollideCallback("Player", "TestDoorScript", "TestFunction", false, 1);
}
void TestFunction(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", false, false);
SetSwingDoorDisableAutoClose("mansion_1", true);
AddTimer("swing_door", 0.001f, "TimerDoor");
}
void TimerDoor(string &in asTimer)
{
AddPropForce("mansion_1", -1000.0f, 0.0f, 0.0f, "world");
}
//This is executed every time you enter the level. Can be executed several times. Can be used for playing music and adding checks.//
void OnEnter()
{
AddEntityCollideCallback("Player", "ReturnPlayerArea_0", "ReturnPlayer", false, 1);
}
void ReturnPlayer(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer("PlayerStartArea_1");
}
//This is executed every time you leave the level. Can be executed several times. Can be used for stopping music//
void OnLeave()
{
}
|
|
06-06-2013, 03:33 AM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Problem with Scripts: AddPropForce not working
AddPropForce must be above 2000 to get visible effects.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
06-06-2013, 04:52 AM |
|
|