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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help MovePlayerForward
Pshyched Offline
Member

Posts: 130
Threads: 21
Joined: Nov 2012
Reputation: 5
#1
MovePlayerForward

Does anyone know how to use the 'MovePlayerForward' Script Function? I just need to make the player move forward a little bit whilst in a Cinematic sequence.
07-03-2013, 04:07 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: MovePlayerForward

You have to use a looping timer.

Example;
void TimerOne(string &in asTimer)
{
MovePlayerForward(4.5f);
AddTimer("", 3, "LoopingTimer");
}

void LoopingTimer(string &in asTimer)
{
AddTimer("", 0.2f, "TimerOne");
}

So to speak.

"Veni, vidi, vici."
"I came, I saw, I conquered."
07-03-2013, 04:23 PM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#3
RE: MovePlayerForward

You can also just spawn a moving wall behind them. I like that better as it takes away the head bob and makes things more cinematic. (for me anyway)

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
07-03-2013, 04:33 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#4
RE: MovePlayerForward

(07-03-2013, 04:23 PM)JustAnotherPlayer Wrote:
Spoiler below!

You have to use a looping timer.

Example;
void TimerOne(string &in asTimer)
{
MovePlayerForward(4.5f);
AddTimer("", 3, "LoopingTimer");
}

void LoopingTimer(string &in asTimer)
{
AddTimer("", 0.2f, "TimerOne");
}

So to speak.


That's not going to be quick enough - that's only going to call MovePlayerForward every 3.2 seconds, the description of the function states "It needs to be called in a timer that updates 60 times / second"
You can also have the timer call the function that it is declared in

void StartPushingPlayer()
{
   PushPlayer(""); // calls PushPlayer once, to start the loop
   AddTimer("KILL_PUSH_LOOP", 5, "KillPushLoop"); // this will stop the pushing loop in the given time
}

void PushPlayer(string &in strTimer)
{
   MovePlayerForward(5); // test the movement speed and adjust this value appropriately
   AddTimer("PUSH_LOOP", 0.016, "PushPlayer"); // this will call PushPlayer again and therefore add another timer
}

void KillPushLoop(string &in strTimer)
{
   RemoveTimer("PUSH_LOOP"); // removes the looping timer, so PushPlayer won't get called again
}

EDIT: changed the code as I realised that the Kill timer was being created repeatedly, which was unnecessary

(This post was last modified: 07-04-2013, 11:39 AM by Adrianis.)
07-03-2013, 05:14 PM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#5
RE: MovePlayerForward

(07-03-2013, 04:33 PM)DeAngelo Wrote: You can also just spawn a moving wall behind them. I like that better as it takes away the head bob and makes things more cinematic. (for me anyway)

cant you just use move playerheadpos?
07-04-2013, 10:41 AM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#6
RE: MovePlayerForward

(07-04-2013, 10:41 AM)The Mug Wrote:
(07-03-2013, 04:33 PM)DeAngelo Wrote: You can also just spawn a moving wall behind them. I like that better as it takes away the head bob and makes things more cinematic. (for me anyway)

cant you just use move playerheadpos?

I've never utilized that particular script myself, but if it somehow removes the head bob, then cool.

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
07-04-2013, 08:57 PM
Find
vengey Offline
Member

Posts: 79
Threads: 7
Joined: Feb 2013
Reputation: 0
#7
RE: MovePlayerForward

Here let me explain it quite simply.


void atwalkto(string &in asTimer)
{
MovePlayerForward(10.0f);
AddTimer("looper", 0.12f, "restart_walk");
}
void restart_walk(string &in asTimer)
{
AddTimer("restarter", 0, "atwalkto");
}

Notice how it is setup
The MovePlayerForward is a SINGLE time event that pushes the player forward, so we need this process to repeat
So we add a timer of a very small time to give the illusion the player is walking
The timer is setup so when the timer goes to zero it activates the method: restart_walk
Within restart_walk we have a timer that is a reseter

It is set to zero so that it automatically returns to the atwalkto method
Then the process repeats
Then you add a script area the player collides with that will cause the process to stop and re-enable the player
void timer13(string &in asTimer)
{
RemoveTimer("looper");
RemoveTimer("restarter");
TeleportPlayer("teleport2");
SetPlayerActive(true);
AddTimer("T14", 1.0f, "timer14");
}

This is a timer that is activated after the player enters the script area
This deletes the timers that were used in the walking simulation which makes sure it doesn't push the player forward anymore and does not loop anymore, then we set the player active again so he can move after the cinematic is done and over with

Before you do anything at all YOU MUST do this BEFORE the moveplayerforward sequence: SetPlayerActive(false);

Now then, if you would like to change the SPEED of the event, there are two methods of going about it.

METHOD 1:
To make the player slower, make the moveplayerforward command have a smaller number and the looper have a tad larger number. To make the player faster do the exact opposite.

METHOD 2:
Use the SetPlayerSpeedMul command to make the player itself slower or faster

(This post was last modified: 07-13-2013, 02:26 AM by vengey.)
07-13-2013, 02:23 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#8
RE: MovePlayerForward

Vengey, good job explaining the rest of the detail & including the part about disabling the player, but I'm not sure if you read the other posts, you've repeated the same mistake as was made above.
A - The MovePlayerForward description says that the function should be called in a timer that updates 60x a second, so the timer should loop every 0.016 seconds rather than 0.12
B - You don't need the 'restart_walk' function to re-declare the timer to call to 'atwalkto', the timer declared in 'atwalkto' can simply call 'atwalkto' again, simplifying the code

void atwalkto(string &in asTimer)
{
    MovePlayerForward(10.0f);
    AddTimer("looper", 0.016f, "atwalkto");
}

(This post was last modified: 07-15-2013, 01:51 PM by Adrianis.)
07-15-2013, 01:50 PM
Find




Users browsing this thread: 2 Guest(s)