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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem With "AddPlayerBodyForce" Func
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#1
Question  Problem With "AddPlayerBodyForce" Func

I made this awesome script and everything works except the player does not change position... Sad

The "AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);" doesn't work. Huh
Any tips or answers?

If you wanted to see the whole script... here you go.

//////////////////////START: ALTARLAMP ROOM

void AltarLampFunc(string &in asParent , string &in asChild , int alState)
{
    StopMusic(0.2f , 10);
    GiveSanityDamage(15 , true);
    SetSwingDoorLocked("cellar_wood01_2" , true , true);
    SetLampLit("altar_lamp_1" , true , true);
    AddTimer("MusicEvent" , 4.0f , "MusicEventFunc");
    AddTimer("PlayerMoveTimer" , 5.0f , "PlayerMoveTimerFunc");
}
void MusicEventFunc(string &in asTimer)
{
    PlayMusic("19_event_brute.ogg" , false , 1.0f , 0.1f , 10.0f , false);
}
void PlayerMoveTimerFunc(string &in asTimer)
{
    AddPlayerBodyForce(0.0 , 2.0 , 0.0 , true);
    AddTimer("PlayerMoveTimer2" , 1.0f , "PlayerMoveTimerFunc2");
}
void PlayerMoveTimerFunc2(string &in asTimer)
{
    AddPlayerBodyForce(2.0 , 0.0 , 0.0 , true);
    AddTimer("PlayerMoveTimer3" , 1.0f , "PlayerMoveTimerFunc3");
}
void PlayerMoveTimerFunc3(string &in asTimer)
{
    AddPlayerBodyForce(-4.0 , 0.0 , 0.0 , true);
    AddTimer("PlayerMoveTimer4" , 1.0f , "PlayerMoveTimerFunc4");
}
void PlayerMoveTimerFunc4(string &in asTimer)
{
    StopMusic(1.0f , 2.0f);
    AddPlayerBodyForce(2.0 , 0.0 , 0.0 , true);
    SetSwingDoorLocked("cellar_wood01_2" , false , true);
    AddTimer("AltarLampOff" , 1.0f , "AltarLampOffFunc");
}
void AltarLampOffFunc(string &in asTimer)
{
    SetLampLit("altar_lamp_1" , false , true);
}

//////////////////////END: ALTARLAMP ROOM

Edit: By the way, the room I put it in keeps on dissapearing... like, wtf?

10-23-2010, 11:58 PM
Find
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#2
RE: Problem With "AddPlayerBodyForce" Func

You're using values like 2.0, and -4.0. To get any significant result, I needed to go as high as 500.0, or 2000.0 (in some cases, 4500.0).

Not only that, but i had to apply that value every twentieth of a second!

Essentially, you're giving the player a very light breeze every second for a brief instant of a moment. You need to apply a much, much higher force over the course of a longer period of time.

Also, while this is a matter of preference, I prefer using the same function for timer situations like that, and just tell them apart using the timer name. "if(asTimer == "PlayerMoveTimer4"){...}" kind of deal. It keeps the code less cluttered for me, in more ifs and less functions.

For example, this would apply a force of 500 whatever's to the player in the X axis every twentieth of a second for 1 second:
void PushPlayer(string &in asTimer)
{
     if(GetLocalVarInt("PushingStage") == 20)
     {
          AddPlayerBodyForce(500.0f, 0.0f, 0.0f, true);
          AddLocalVarInt("PushingStage", 1);
          AddTimer("Blah", 0.05f, "PushPlayer");
     }
}

It's your job as a script writer to find a way to work in that idea though, always the hard part.

As per the room... mind clarifying a little?
10-24-2010, 02:52 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#3
RE: Problem With "AddPlayerBodyForce" Func

Thanks, I thought the "-4" and the "2" actually move you on the grid that much.

The problem about the room is that whenever the altar_lamp_1 and the ScriptArea_5 (which was in the callback) are in the same room, it disapears from the last time I edited the place...

Edit: Is it all right to remove the cache file? I don't know, it's just that it won't show anything that was from the last save I did in the editor! Nothing changed... Sad

10-24-2010, 12:58 PM
Find
anzki Offline
Member

Posts: 88
Threads: 6
Joined: Apr 2010
Reputation: 1
#4
RE: Problem With "AddPlayerBodyForce" Func

Yes it is all right to remove cache file.

[Image: 2qnr5av.png]
10-24-2010, 04:05 PM
Find
nofsky Offline
Senior Member

Posts: 423
Threads: 13
Joined: Sep 2008
Reputation: 1
#5
RE: Problem With "AddPlayerBodyForce" Func

Kyle, you might want to check out this thread http://www.frictionalgames.com/forum/thread-4822.html if you're having trouble with changes you make not being visible in the game.
10-24-2010, 06:49 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: Problem With "AddPlayerBodyForce" Func

It shows the altar_lamp, the door, and the scriptarea_5 but whenever I make another room, it just disapears... Sad

Any idea?

Is there a boundary that goes to the edge of the editing area? -_-

10-24-2010, 11:55 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#7
RE: Problem With "AddPlayerBodyForce" Func

Cool! I fixed it! Thanks guys for all your help and suggestions! Smile

10-25-2010, 02:57 AM
Find




Users browsing this thread: 2 Guest(s)