Frictional Games Forum (read-only)
Player reacting when looking at a area - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Player reacting when looking at a area (/thread-7203.html)



Player reacting when looking at a area - Henriksen - 04-05-2011

Hi.

Is it possible to do so that when the player LOOKS at a area it triggers a function?

If so please post a full example Smile


RE: Player reacting when looking at a area - Tanshaydar - 04-05-2011

There should be a PlayerLookAtCallback for entities. For areas...

void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

Calls a function when the player looks at a certain entity.
Callback syntax: void MyFunc(string &in entity, int alState)
alState: 1 = looking, -1 = not looking

asName - internal name
asCallback - function to call
abRemoveWhenLookedAt - determines whether the callback should be removed when the player looked at the entity


RE: Player reacting when looking at a area - Henriksen - 04-05-2011

(04-05-2011, 04:26 PM)Tanshaydar Wrote: There should be a PlayerLookAtCallback for entities. For areas...

void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

Calls a function when the player looks at a certain entity.
Callback syntax: void MyFunc(string &in entity, int alState)
alState: 1 = looking, -1 = not looking

asName - internal name
asCallback - function to call
abRemoveWhenLookedAt - determines whether the callback should be removed when the player looked at the entity

I dont understand? Could you give me an example or is it something like:

void SetEntityPlayerLookAtCallback("AREA", "FUNCTION", true);


RE: Player reacting when looking at a area - Anxt - 04-05-2011

Let's say your area is named "AreaScare". Let's call the Function "LookScare".

So, in your OnStart() function, you need what Tanshaydar posted above:

SetEntityPlayerLookAtCallback("AreaScare", "LookScare", true);

Then you would have your function later on in the code:

void LookScare(string &in asEntity, int alState)
{
//Whatever you want to happen goes here
}

You can use if statements to check the state by using:

if(alState==1)
{
//Whatever you want to happen goes here
}

-1 is also a valid number for alState.


RE: Player reacting when looking at a area - Itskody - 04-06-2011

I have a question, i have it so when my guy looks at a pig which is in the cabinet, he gets scared, but before my guy even opens the cabinet he gets scared from look at the pig. i dont get how to fix it so he gets scared by just looking at the pig, not the cabinet


RE: Player reacting when looking at a area - Tanshaydar - 04-06-2011

Hmm, that's strange. Game takes it as player actually sees the pig, where he does not.