Frictional Games Forum (read-only)

Full Version: Look At
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i want to set an entity active, when the player looks at an area. i saw this http://www.frictionalgames.com/forum/thread-18368.html

but i didnt understand it. i always get fatal error.

my code now:

SetEntityPlayerLookAtCallback("area_lookat_1", true, 1);



void area_lookat_1(string &in asEntity, int alState)
{
SetEntityActive ("armour_nice_complete_4", true);
SetEntityActive ("armour_nice_complete_5", true);
SetEntityActive ("armour_nice_complete_6", true);
SetEntityActive ("armour_nice_complete_7", true);
SetEntityActive ("armour_nice_complete_8", true);
}
You are close.

If you know basic scripting then you should know that a .hps file should have

void OnEnter()
{

}


void OnLeave()
{

}


void OnStart()
{

}

What you need now is to place the first line in void OnStart() and then add the rest of the script like this:

EDIT: I just realized you haven't specified what entity you want to look at. The script line is:


SetEntityPlayerLookAtCallback("ENTITY", "CALLBACK", "false/true")

void OnStart()
{
SetEntityPlayerLookAtCallback("area_lookat_1", "LookAtFunction", true);

}

void LookAtFunction(string &in asEntity, int alState)
{
if(alState == 1)
{
SetEntityActive ("armour_nice_complete_4", true);
SetEntityActive ("armour_nice_complete_5", true);
SetEntityActive ("armour_nice_complete_6", true);
SetEntityActive ("armour_nice_complete_7", true);
SetEntityActive ("armour_nice_complete_8", true);
}

}


I added a little but to the script, so it works better. What i did was saying, if > only when the player crosshair goes into the area > call the script
(Not when it goes outside)
This can always be useful later on Wink
sure i know that i need void on start enter leave etc. i just piceked up the needed lines for this thread Wink but thanks i will try it out