Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Player reacting when looking at a area
Henriksen Offline
Senior Member

Posts: 308
Threads: 71
Joined: Dec 2010
Reputation: 2
#1
Player reacting when looking at a area

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
04-05-2011, 04:19 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: Player reacting when looking at a area

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
Website Find
Henriksen Offline
Senior Member

Posts: 308
Threads: 71
Joined: Dec 2010
Reputation: 2
#3
RE: Player reacting when looking at a area

(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);
04-05-2011, 04:31 PM
Find
Anxt Offline
Senior Member

Posts: 588
Threads: 12
Joined: Mar 2011
Reputation: 10
#4
RE: Player reacting when looking at a area

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.

04-05-2011, 04:49 PM
Find
Itskody Offline
Member

Posts: 100
Threads: 30
Joined: Mar 2011
Reputation: 1
#5
RE: Player reacting when looking at a area

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
04-06-2011, 06:40 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#6
RE: Player reacting when looking at a area

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

04-06-2011, 12:06 PM
Website Find




Users browsing this thread: 3 Guest(s)