Frictional Games Forum (read-only)
Script - Force Player to Look in Direction - 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: Script - Force Player to Look in Direction (/thread-9272.html)



Script - Force Player to Look in Direction - Rokotain - 07-20-2011

Hello Forum People! Big Grin

I'm quite new to scripting and don't understand 100% of Frictional Games's Scripting Tutorial. Blush

What I have is a grunt spawning and I would like to have a script that forces the player to look at the grunt for a certain amount of time.

I read another thread where I found:
StartPlayerLookAt("Name?", 5.0f, 5.0f, "");
But I don't understand what it means, are "5.0f" coordinates? and the "Name?" is that the name of a Script Area Entity or an Object/Enemy Entity?

The place it would be is in this:
Code:
void LookAtGrunt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("ghostgrunt", true);
    ShowEnemyPlayerPosition("ghostgrunt");
    AddTimer("", 2, "TimerGruntEnd");
        (>- Here -<)
}

Don't worry about the "LookAtGrunt" name in top, already got figured out how to activate that script.

So how would I get the player to look at the place the grunt is standing/spawns/area, we.

Also, I'm Norwegian so please excuse me if there are any typos. Angel

Thanks for reading!
Hope you have a solution! ^-^
Rokotain


RE: Script - Force Player to Look in Direction - xtron - 07-20-2011

Code:
void LookAtGrunt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("ghostgrunt", true);
    ShowEnemyPlayerPosition("ghostgrunt");
    AddTimer("", 2, "TimerGruntEnd");
   StartPlayerLookAt("MonsterName", 10, 50, "");
   AddTimer("", 2, "TimerStopPlayerLook");
}

void TimerStopPlayerLook (string &in asTimer)
{
StopPlayerLookAt();
}

void StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
void StopPlayerLookAt();

Forces the player to look at a certain entity until StopPlayerLookAt is used.

asEntityName - the entity to look at
afSpeedMul - how fast should the player look at the entity
afMaxSpeed - maximum speed allowed
asAtTargetCallback - function to call when player looks at target


RE: Script - Force Player to Look in Direction - Rokotain - 07-21-2011

Thank you! Big Grin

I have tested it, and it works perfectly fine.
This will create a nasty surprise hehe^^

Thanks again for your time replying on this.
-Rokotain


RE: Script - Force Player to Look in Direction - xtron - 07-21-2011

No problem Smile