Frictional Games Forum (read-only)
[SOLVED] StartPlayerLookAt following a grunt? - 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: [SOLVED] StartPlayerLookAt following a grunt? (/thread-29658.html)



[SOLVED] StartPlayerLookAt following a grunt? - Aletho - 02-25-2015

Hello!

I want to force the player to look at where the monster would be, behind the wall, and follow its movements past the door, simulating the player following the origin of the sound the monster is making.

Is there any way to do this? So far I've only managed to get the player to look at the point where the monster spawns.

Thanks in advance! Big Grin


RE: StartPlayerLookAt following a grunt? - Mudbill - 02-25-2015

I've had the player's view follow the monster just fine. All I did was the expected StartPlayerLookAt with the monster as the target. Only thing I remember doing in addition was SetPlayerActive(false); but I don't know if that really makes the difference.


RE: StartPlayerLookAt following a grunt? - Aletho - 02-25-2015

(02-25-2015, 08:22 PM)Mudbill Wrote: I've had the player's view follow the monster just fine. All I did was the expected StartPlayerLookAt with the monster as the target. Only thing I remember doing in addition was SetPlayerActive(false); but I don't know if that really makes the difference.

This is my code for the monster/looking script:

Spoiler below!
void MonsterBeginning(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",true);

AddEnemyPatrolNode("grunt","beginning_node_1",0,"");
StartPlayerLookAt("grunt", 5.0f, 15.0f, "");
}


but this makes the player look at the point of origin of the monster and stays there, instead of following the monster :/


RE: StartPlayerLookAt following a grunt? - Neelke - 02-25-2015

Then what you can do is update the StartPlayerLookAt with a timer. The camera should then adjust perfectly by itself with this.

Code:
void TimerGruntUpdate(string &in asTimer)
{
StartPlayerLookAt("grunt", 3.0f, 3.0f, "");
AddTimer("grunt", 0.01f, "TimerGruntUpdate");
}



RE: StartPlayerLookAt following a grunt? - Aletho - 02-25-2015

(02-25-2015, 08:58 PM)Neelke Wrote: Then what you can do is update the StartPlayerLookAt with a timer. The camera should then adjust perfectly by itself with this.

Code:
void TimerGruntUpdate(string &in asTimer)
{
StartPlayerLookAt("grunt", 3.0f, 3.0f, "");
AddTimer("grunt", 0.01f, "TimerGruntUpdate");
}

That worked really well, now the camera follows the grunt perfectly. There's just one problem, now that script will go on forever meaning a simple "StopPlayerLookingAt" line won't stop it from looking at the point where the grunt got deactivated, since it updates itself every 1/10 of a second :/


RE: StartPlayerLookAt following a grunt? - Mudbill - 02-26-2015

Use RemoveTimer("grunt"); at the same time as the StopPlayerLookAt script. That will cancel the loop.


RE: StartPlayerLookAt following a grunt? - Aletho - 02-26-2015

(02-26-2015, 12:06 AM)Mudbill Wrote: Use RemoveTimer("grunt"); at the same time as the StopPlayerLookAt script. That will cancel the loop.

Ahh thanks, that worked! :-)