Frictional Games Forum (read-only)
[SCRIPT] [SOLVED] AddBodyForce doesn't work - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] [SOLVED] AddBodyForce doesn't work (/thread-18182.html)

Pages: 1 2


[SOLVED] AddBodyForce doesn't work - Kiwi2703 - 09-06-2012

Hey Smile
I have an area called ScriptArea_2. I want the player to be pushed forward (about 1 meter) and slighty upward (~0.2m) when he collides with the area.
The script looks like this:

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_2", "theforce", true, 1);
}

void theforce(string &in asParent, string &in asChild, int alState)
{
AddBodyForce("Player", 0.0f, 500.0f, 5000.0f, "world");
}

I set the values so high only for experimental purposes. The problem is, when I walk into the area, absolutely nothing happens.
Any help? Thanks! Smile


RE: AddBodyForce doesn't work - Robby - 09-06-2012

(09-06-2012, 06:35 PM)Kiwi2703 Wrote: Hey Smile
I have an area called ScriptArea_2. I want the player to be pushed forward (about 1 meter) and slighty upward (~0.2m) when he collides with the area.
The script looks like this:

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_2", "theforce", true, 1);
}

void theforce(string &in asParent, string &in asChild, int alState)
{
AddBodyForce("Player", 0.0f, 500.0f, 5000.0f, "world");
}

I set the values so high only for experimental purposes. The problem is, when I walk into the area, absolutely nothing happens.
Any help? Thanks! Smile
I don't see anything wrong with this. Have you created the script file while the map was open in Amnesia? If yes, close Amnesia, then start it again.

Also, are the names correct? Triple-check, to be sure.


RE: AddBodyForce doesn't work - Kreekakon - 09-06-2012

Try this command instead:
Code:
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);



RE: AddBodyForce doesn't work - EXAWOLT - 09-06-2012

AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);


RE: AddBodyForce doesn't work - Robby - 09-06-2012

Yeah, didn't think of ^. Try that instead.

LOL, 2 posts on the same time.


RE: AddBodyForce doesn't work - EXAWOLT - 09-06-2012

haha, this do happen us some times^^


RE: AddBodyForce doesn't work - Kiwi2703 - 09-06-2012

(09-06-2012, 06:44 PM)Kreekakon Wrote:
Code:
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);
It worked but I had to set the values to 10000.0f and higher... no idea why it wants so much power Huh
Many thanks anyways! Smile


RE: AddBodyForce doesn't work - EXAWOLT - 09-06-2012

about the callback:
Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.


RE: AddBodyForce doesn't work - Robby - 09-06-2012

(09-06-2012, 06:52 PM)Kiwi2703 Wrote:
(09-06-2012, 06:44 PM)Kreekakon Wrote:
Code:
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);
It worked but I had to set the values to 10000.0f and higher... no idea why it wants so much power Huh
Many thanks anyways! Smile

Note that rather high values are needed when applying forces.

[align=start]
As said on the script functions page located on the wiki.
[/align]


RE: AddBodyForce doesn't work - Kiwi2703 - 09-06-2012

(09-06-2012, 06:56 PM)Nemet Robert Wrote:
(09-06-2012, 06:52 PM)Kiwi2703 Wrote:
(09-06-2012, 06:44 PM)Kreekakon Wrote:
Code:
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);
It worked but I had to set the values to 10000.0f and higher... no idea why it wants so much power Huh
Many thanks anyways! Smile

Note that rather high values are needed when applying forces.

[align=start]
As said on the script functions page located on the wiki.
[/align]

Actually, on the scripts page were some really low values.. like 3.5f and such