Frictional Games Forum (read-only)

Full Version: [SOLVED] StartPlayerLookAt following a grunt?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
(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 :/
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");
}
(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 :/
Use RemoveTimer("grunt"); at the same time as the StopPlayerLookAt script. That will cancel the loop.
(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! :-)