Frictional Games Forum (read-only)

Full Version: Player reacting when looking at a area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
(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);
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.
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
Hmm, that's strange. Game takes it as player actually sees the pig, where he does not.