Frictional Games Forum (read-only)
Unwanted teleportation loop - 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: Unwanted teleportation loop (/thread-27112.html)



Unwanted teleportation loop - ShadowTV - 11-05-2014

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!


RE: Unwanted teleportation loop - DnALANGE - 11-05-2014

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

You loop the entire function called : void moveplayertimer


RE: Unwanted teleportation loop - FlawlessHappiness - 11-06-2014

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:
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);


RE: Unwanted teleportation loop - ShadowTV - 11-06-2014

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:
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


RE: Unwanted teleportation loop - FlawlessHappiness - 11-06-2014

(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:
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.


RE: Unwanted teleportation loop - ShadowTV - 11-06-2014

(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:
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.





RE: Unwanted teleportation loop - FlawlessHappiness - 11-06-2014

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.


RE: Unwanted teleportation loop - ShadowTV - 11-06-2014

(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