Frictional Games Forum (read-only)

Full Version: Push up door smooth script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Do anyone know a script that makes a door get pushed open when the player collides with an area,
if you do please post it down here and i would be pleased Smile!
I know you guys know this so im already saying thank you :p
Quote:void AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddBodyForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddBodyImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
Pushes objects. Note that rather high values are needed when applying forces.
asName - the object to push
afX - direction along the X-axis
afY - direction along the Y-axis
afZ - direction along the Z-axis
asCoordSystem - determines which coordinate system is used, usually “world”

Try using an impulse to open the door. I've had problems in the past with this, and you're bound to run into them as well. You need to make it so that the door does not "snap" into the closed position with this:
Quote:void SetSwingDoorDisableAutoClose(string& asName, bool abDisableAutoClose);
Deactivates the “auto-close” when a door is nearly closed.

And then set the door to be just a little open already. You do that in the editor. You click on the door, and set its open amount to 0.1.

Now when the player enters an area, add a prop impulse to open the door. You'll have to do some trial and error to get just the right amount of impulse.
(05-22-2012, 09:48 PM)FragdaddyXXL Wrote: [ -> ]
Quote:void AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddBodyForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void AddBodyImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
Pushes objects. Note that rather high values are needed when applying forces.
asName - the object to push
afX - direction along the X-axis
afY - direction along the Y-axis
afZ - direction along the Z-axis
asCoordSystem - determines which coordinate system is used, usually “world”

Try using an impulse to open the door. I've had problems in the past with this, and you're bound to run into them as well. You need to make it so that the door does not "snap" into the closed position with this:
Quote:void SetSwingDoorDisableAutoClose(string& asName, bool abDisableAutoClose);
Deactivates the “auto-close” when a door is nearly closed.

And then set the door to be just a little open already. You do that in the editor. You click on the door, and set its open amount to 0.1.

Now when the player enters an area, add a prop impulse to open the door. You'll have to do some trial and error to get just the right amount of impulse.

thank you i'll try Smile!
(05-22-2012, 09:48 PM)FragdaddyXXL Wrote: [ -> ]
Quote:so i tryed but i got an error on line 123

void opening(string &in asParent, string &in asChild, int alState)
{
122 SetSwingDoorDisableAutoClose("castle", true);
123 AddPropImpulse("castle", 0f, 0f, -900f, "world");
}
it said expected , or ) help Smile?
(05-23-2012, 12:14 PM)stevenbocco Wrote: [ -> ]
(05-22-2012, 09:48 PM)FragdaddyXXL Wrote: [ -> ]
Quote:so i tryed but i got an error on line 123

void opening(string &in asParent, string &in asChild, int alState)
{
122 SetSwingDoorDisableAutoClose("castle", true);
123 AddPropImpulse("castle", 0f, 0f, -900f, "world");
}
it said expected , or ) help Smile?
That means that it's expecting there to be a finishing parenthesis ) or it's missing a ,

Also, that -900f is going to send the door into the 4th dimension. Try something around -15f for starters. Big Grin

As for the error, try looking for a missing: " or ) or a comma. I can't see where the error is, and it leads me to believe a few things:
You may have not hit "Save" in the text editor before starting up the level (happens to me all the time), or
the exception is in another area close to line 123 or
I'm blind xD.
This is because you're using integers, not floats. It will looks like:
Code:
void opening(string &in asParent, string &in asChild, int alState)
{
122 SetSwingDoorDisableAutoClose("castle", true);
123 SetSwingDoorClosed("castle", false, true); //Yes, you could add it
124 AddPropImpulse("castle", 0.0f, 0.0f, -20.0f, "world");
}
(05-29-2012, 10:47 AM)paththeir Wrote: [ -> ]This is because you're using integers, not floats. It will looks like:
Code:
void opening(string &in asParent, string &in asChild, int alState)
{
122 SetSwingDoorDisableAutoClose("castle", true);
123 SetSwingDoorClosed("castle", false, true); //Yes, you could add it
124 AddPropImpulse("castle", 0.0f, 0.0f, -20.0f, "world");
}
Actually, you should find that the script engine deals with it in the same way if you have used -20, -20.0 or -20.0f. Unless there is a limitation I am not yet aware of, I have always taken the simplest option of not defining the .0 decimal even with a float, and have not used the 'f' afterwards either, haven't come across any problems as a result. If someone knows better I would love to be corrected on that, to save future problems Tongue

If the wrong data type was being used the error message should be more like 'no matching signature to AddPropImpulse(string, float, float, int, string)'