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
Unwanted teleportation loop
ShadowTV Offline
Junior Member

Posts: 11
Threads: 3
Joined: Sep 2013
Reputation: 0
#1
Sad  Unwanted teleportation loop

Hey guys,

I once again need help with my custom story.
This time I made a teleportation to a position in my intro map.

The problem here is:
1. It keeps teleporting me to the same position without a loop.
2. My view snaps back to the direction of the "PlayerStartArea_3".
3. I can't move forwards/backwards/left/right (just a few cm).

Here is the .hps file of my map:
Spoiler below!

void OnStart()
{
//LOCAL VARIABLES

//ADDENTITYCOLLIDECALLBACK
AddEntityCollideCallback("Player", "StartIntro", "IntroStart", true, 1);

//ADDTIMER


//FUNCTIONS
FadeOut(0.0);
}
//START INTRO//
void IntroStart(string &in asParent, string &in asChild, int alState)
{
FadeIn(1.5f);
AddTimer("MovePlayer", 0.1, "MovePlayerTimer");
}

void MovePlayerTimer(string &in asTimer)
{
MovePlayerForward(5.0);
AddTimer("MovePlayer", 0.1, "MovePlayerTimer");
AddTimer("ShowFirstMessage", 3.0, "ShowFirstMessageTimer");
}
//END INTRO//

//START FIRST MESSAGE//
void ShowFirstMessageTimer(string &in asTimer)
{
//SetMessage("TextDisplay", "FirstMessage", 5.0);
AddTimer("NextStart", 3.0, "NextStartTimer");
}
//END FIRST MESSAGE//

//START NEXT START TIMER//
void NextStartTimer(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
AddTimer("DisablePSA3", 0.1, "DisablePSA3");
}

void DisablePSA3(string &in asTimer)
{
SetEntityActive("PlayerStartArea_3", false);
}

//START SECOND MESSAGE//
void ShowSecondMessageTimer(string &in asTimer)
{
//SetMessage("TextDisplay", "SecondMessage", 5.0);
//AddTimer("NextStart_1", 2.0, "NextStartTimer_1");
}
//END SECOND MESSAGE//

/*//START NEXT START_1//
void NextStartTimer_1(string &in asTimer)
{

}*/

void OnEnter()
{

}


void OnLeave()
{

}


I can't find a loop with "AddTimer" or any other loop. Sad

Thanks for any answer!

11-05-2014, 09:50 PM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#2
RE: Unwanted teleportation loop

Here is a timer witch called in a loop.
Moveplayertimer... 0.1 seconds it loops.

You loop the entire function called : void moveplayertimer
(This post was last modified: 11-05-2014, 10:45 PM by DnALANGE.)
11-05-2014, 10:44 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Unwanted teleportation loop

To make a player walk forward you need to call the script-line, MovePlayerForward, once every 0,1 second.
You're only calling it once, meaning nothing really happens.

Simply create your own function that can repeat itself. Like this:

PHP Code: (Select All)
void MovePlayerForward(string &in asTimer)
{
if(
GetLocalVarInt("StopTimer") == 0)
{
MovePlayerForward(1.0);
AddTimer(""0.1"MovePlayerForward");
}


Now to stop the timer use this line: SetLocalVarInt("StopTimer", 1);

Trying is the first step to success.
11-06-2014, 12:07 PM
Find
ShadowTV Offline
Junior Member

Posts: 11
Threads: 3
Joined: Sep 2013
Reputation: 0
#4
RE: Unwanted teleportation loop

Spoiler below!

(11-06-2014, 12:07 PM)FlawlessHappiness Wrote: To make a player walk forward you need to call the script-line, MovePlayerForward, once every 0,1 second.
You're only calling it once, meaning nothing really happens.

Simply create your own function that can repeat itself. Like this:

PHP Code: (Select All)
void MovePlayerForward(string &in asTimer)
{
if(
GetLocalVarInt("StopTimer") == 0)
{
MovePlayerForward(1.0);
AddTimer(""0.1"MovePlayerForward");
}


Now to stop the timer use this line: SetLocalVarInt("StopTimer", 1);
(11-05-2014, 10:44 PM)DnALANGE Wrote: Here is a timer witch called in a loop.
Moveplayertimer... 0.1 seconds it loops.

You loop the entire function called : void moveplayertimer


I want my player to move foward, but he stucks in position after he teleports.
I think it's a problem with my 'NextStartTimer' timer callback.

Or is it a bug with TeleportPlayer(); or SetPlayerPos();?
None of both made a difference, they made me stuck in position... Sad

Thanks anyways! Smile

(This post was last modified: 11-06-2014, 01:52 PM by ShadowTV.)
11-06-2014, 01:45 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Unwanted teleportation loop

(11-06-2014, 01:45 PM)ShadowTV Wrote:
Spoiler below!

(11-06-2014, 12:07 PM)FlawlessHappiness Wrote: To make a player walk forward you need to call the script-line, MovePlayerForward, once every 0,1 second.
You're only calling it once, meaning nothing really happens.

Simply create your own function that can repeat itself. Like this:

PHP Code: (Select All)
void MovePlayerForward(string &in asTimer)
{
if(
GetLocalVarInt("StopTimer") == 0)
{
MovePlayerForward(1.0);
AddTimer(""0.1"MovePlayerForward");
}


Now to stop the timer use this line: SetLocalVarInt("StopTimer", 1);
(11-05-2014, 10:44 PM)DnALANGE Wrote: Here is a timer witch called in a loop.
Moveplayertimer... 0.1 seconds it loops.

You loop the entire function called : void moveplayertimer


I want my player to move foward, but he stucks in position after he teleports.
I think it's a problem with my 'NextStartTimer' timer callback.

Or is it a bug with TeleportPlayer(); or SetPlayerPos();?
None of both made a difference, they made me stuck in position... Sad

Thanks anyways! Smile

Well that's because you have nothing that moves him forward.

Make a time that moves him forward, and he should be doing it.

Trying is the first step to success.
11-06-2014, 02:03 PM
Find
ShadowTV Offline
Junior Member

Posts: 11
Threads: 3
Joined: Sep 2013
Reputation: 0
#6
RE: Unwanted teleportation loop

(11-06-2014, 02:03 PM)FlawlessHappiness Wrote:
(11-06-2014, 01:45 PM)ShadowTV Wrote:
Spoiler below!

(11-06-2014, 12:07 PM)FlawlessHappiness Wrote: To make a player walk forward you need to call the script-line, MovePlayerForward, once every 0,1 second.
You're only calling it once, meaning nothing really happens.

Simply create your own function that can repeat itself. Like this:

PHP Code: (Select All)
void MovePlayerForward(string &in asTimer)
{
if(
GetLocalVarInt("StopTimer") == 0)
{
MovePlayerForward(1.0);
AddTimer(""0.1"MovePlayerForward");
}


Now to stop the timer use this line: SetLocalVarInt("StopTimer", 1);
(11-05-2014, 10:44 PM)DnALANGE Wrote: Here is a timer witch called in a loop.
Moveplayertimer... 0.1 seconds it loops.

You loop the entire function called : void moveplayertimer


I want my player to move foward, but he stucks in position after he teleports.
I think it's a problem with my 'NextStartTimer' timer callback.

Or is it a bug with TeleportPlayer(); or SetPlayerPos();?
None of both made a difference, they made me stuck in position... Sad

Thanks anyways! Smile

Well that's because you have nothing that moves him forward.

Make a time that moves him forward, and he should be doing it.

He tries to move foward, but he gets teleported back to the PlayerStartArea.



(This post was last modified: 11-06-2014, 02:31 PM by ShadowTV.)
11-06-2014, 02:29 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Unwanted teleportation loop

void MovePlayerTimer(string &in asTimer)
{
MovePlayerForward(5.0);
AddTimer("MovePlayer", 0.1, "MovePlayerTimer");
AddTimer("ShowFirstMessage", 3.0, "ShowFirstMessageTimer");
}

This timer is repeatedly calling itself.
Meaning it's also calling this timer:

void ShowFirstMessageTimer(string &in asTimer)
{
//SetMessage("TextDisplay", "FirstMessage", 5.0);
AddTimer("NextStart", 3.0, "NextStartTimer");
}

Meaning it's also calling this timer:

void NextStartTimer(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
AddTimer("DisablePSA3", 0.1, "DisablePSA3");
}


You're literally teleporting yourself over and over, because the timer is repeating.

Trying is the first step to success.
(This post was last modified: 11-06-2014, 02:51 PM by FlawlessHappiness.)
11-06-2014, 02:50 PM
Find
ShadowTV Offline
Junior Member

Posts: 11
Threads: 3
Joined: Sep 2013
Reputation: 0
#8
RE: Unwanted teleportation loop

(11-06-2014, 02:50 PM)FlawlessHappiness Wrote: void MovePlayerTimer(string &in asTimer)
{
MovePlayerForward(5.0);
AddTimer("MovePlayer", 0.1, "MovePlayerTimer");
AddTimer("ShowFirstMessage", 3.0, "ShowFirstMessageTimer");
}

This timer is repeatedly calling itself.
Meaning it's also calling this timer:

void ShowFirstMessageTimer(string &in asTimer)
{
//SetMessage("TextDisplay", "FirstMessage", 5.0);
AddTimer("NextStart", 3.0, "NextStartTimer");
}

Meaning it's also calling this timer:

void NextStartTimer(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
AddTimer("DisablePSA3", 0.1, "DisablePSA3");
}


You're literally teleporting yourself over and over, because the timer is repeating.

Oh, I see. It worked! THANK YOU! Smile

+rep

(This post was last modified: 11-06-2014, 02:58 PM by ShadowTV.)
11-06-2014, 02:57 PM
Find




Users browsing this thread: 1 Guest(s)