Frictional Games Forum (read-only)

Full Version: AddBodyForce Cabinet Doors Script Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello guys,

i want to get the two nice cabinet doors fast open with the BodyForce-Command. I dont know, whats the problem in this script Sad

Code:
SetSwingDoorDisableAutoClose("cabinet_nice_2", true);
  SetSwingDoorLocked("cabinet_nice_2",false,true);
  StartPlayerLookAt("lookatentitycabinet", 2, 2, "");
  SetMessage("Intro", "Intro11", 2.0f);
  AddEntityCollideCallback("Player", "Furniture_Shock_Area", "cabinetscare", true, 1);
}

void cabinetscare (string &in asParent, string &in asChild, int alState)
{  
  PlaySoundAtEntity("cabinetopensound","break_wood.snt","Player",0.1f,false);
  AddBodyForce("cabinet_nice_2_Body_1",0,0,-2000,"world");
  AddBodyForce("cabinet_nice_2_Body_2",0,0,-2000,"world");
  AddPlayerBodyForce(0, 0, -30000, false);          
  SetEntityActive("servant_grunt_1", true);
  SetPlayerSanity(0.4f);
  FadeOut(1.0f);
  ChangeMap("map_1", "PlayerStartArea_1","","");
}

I want to open it in the same direction like "AddPlayerBodyForce", which works correctly, but by the cabinet nothing happens, just a little bugging...

PS: sry for my bad english, i am german ^.^
PPS: its not the whole code, i just copied that, which is important ^-^
I *think* that only works for the player.

Try using AddPropForce.

PHP Code:
void AddPropForce(stringasNamefloat afXfloat afYfloat afZstringasCoordSystem);
//Name of the prop etc, force along X, Y, Z axes, and the coordinate system. "world" I think. 
No, i tried it already Sad

for Player its the AddPlayerBodyForce


I also tried Prop- and BodyImpulse. SetSwingDoorClosed is too low for my CS.
Perhaps you're doing it from the wrong direction. Also check if the cabinet is locked.
The door and the body is actually two different models put together by the Body. You need to direct it to the door, not the body, which is impossible (I think).
Quote: Perhaps you're doing it from the wrong direction. Also check if the cabinet is locked.
PHP Code:
SetSwingDoorDisableAutoClose("cabinet_nice_2"true);
SetSwingDoorLocked("cabinet_nice_2",false,true); 

I already unlocked it Wink

and:

PHP Code:
AddPropForce("cabinet_nice_2_Body_1",0,0,-2000,"world");  AddPropForce("cabinet_nice_2_Body_2",0,0,-2000,"world");  
AddPlayerBodyForce(00, -30000false); 


the AddPlayerBodyForce goes to the right direction, and i think this is the direction, were the cabinetdoors have to go (the player goes backwards)

Quote: The door and the body is actually two different models put together by the Body. You need to direct it to the door, not the body, which is impossible (I think).
the 2 doors are two bodies (Body_1 and Body_2). Because that i think AddBodyForce, and when i take the value to 30000, the doors are bugging around -> something happens, but not that, what i want Big Grin
This would be a bit roundabout, but you could try this: Make a new entity that is a move object, but is invisible. (You could just modify the blockbox and save it as a new entity)

Then place them in the level at the right angles so that when you move them (and move them rather fast but a short distance) they will "smack" the doors.

As I said, a bit roundabout but it should achieve what you want.
Sorry, i dont understand much about entitys, modeleditor etc. Big Grin

I used this tutorial:

http://wiki.frictionalgames.com/hpl2/tut...hdoorsopen

Edit: Really no one know whats the problem ?? The Tutorials says, its going, but... I need it so much Sad
(06-13-2013, 02:30 PM)DeAngelo Wrote: [ -> ]This would be a bit roundabout, but you could try this: Make a new entity that is a move object, but is invisible. (You could just modify the blockbox and save it as a new entity)

Then place them in the level at the right angles so that when you move them (and move them rather fast but a short distance) they will "smack" the doors.

As I said, a bit roundabout but it should achieve what you want.
Actually that's an awesome idea.
I don't know if applying it here it's the best solution but it's great for more complex stuff. So i'll keep it in mind in case i ever need it. +rep DeAngelo.

Mazl,

I always use BodyImpulse and is working for me.
I just put the cabinet in my map, wrote this line and it opened one door as it should.


AddBodyImpulse( "cabinet_nice_1_Body_1", 5, 0, 5, "" );




(06-15-2013, 03:41 AM)Amn Wrote: [ -> ]Actually that's an awesome idea.
I don't know if applying it here it's the best solution but it's great for more complex stuff. So i'll keep it in mind in case i ever need it. +rep DeAngelo.

Mazl,

I always use BodyImpulse and is working for me.
I just put the cabinet in my map, wrote this line and it opened one door as it should.


AddBodyImpulse( "cabinet_nice_1_Body_1", 5, 0, 5, "" );





I've only been working with HPL for a few months and in that time I've had to learn the editor from scratch, scripting from scratch, and model editor from scratch (I was thinking about learning blender, but that's a can of worms I'm not gonna open till my first CS is done)

and the one thing I've learned about HPL, is no matter the scope of your custom story, you WILL run into a situation where the engine just can't do what you want. In these instances, you either cut your losses and move on, or you improvise.

For instance, I have a wedding flashback in my story, where I force the player to "walk down the aisle" but the normal "force player to walk" script I didn't like because of the head bobble. I could've cut my losses, but I had already spent about 4 hours building the church (4 hours on something the player will see for a 3 second flashback, story of the Amnesia CS creators life, am I right?) so what I did was took a painting, modified it to be a move object, turned it sideways and plopped the player on it. Now they glide beautifully during the scene. In essence I turned a work of art into a surf board. Amazing what you can do in HPL with some improvising. Smile
Pages: 1 2