I don't know if this has been done but here it is:
Okay, you're going to need to make a script area (8) (make sure it is a script area) and place it where you want the player to look, and make it's name to what ever you like (I named it LOOK for the tutorial).Also put a ScriptArea so that when the player walks in it, the function is triggered Like so (I named this "PLAYERLOOK"):
1-1.jpg (Size: 103.62 KB / Downloads: 235)
Once you have done that, we can get into the scripting!
What you will need to put in void OnStart() is this:
AddEntityCollideCallback("Player" , "PLYAERLOOK" , "Look" , true , 1);
This means that when the player collides with the Script Area the "Look" function will come into play
Now we have to put this code in anywhere BUT inside void OnStart():
void Look(string &in asParent, string &in asChild, int alState){ StartPlayerLookAt("LOOK1", 6, 6, "notneededfortutorial");}
This means, that when the "Look" function is triggered, the player will look at the scriptarea "LOOK1", which we placed earlier. The 6, 6 are the rate on how fast the Player looks at the script area. The first 6 is for how fast it goes, and the other 6 is for how fast it can go. The "notneededfortutorial" is not needed in the tutorial (ironic) but for those who want to know; you put the name of another function so that it will call it once the scriptarea has been looked at.... E.G: When the player looks at the area, a monster spawns somewhere)
Now that we have the player looking at the ScriptArea, we want him to stop, not look at it forever.
For this, we have to use timers. This make's it alot easier as it tells the game when it should activate another function in accordance to the time you put in. Here's the script:
AddTimer("look01", 1.0f, "Timer_1");
This means that the name of this is that "look01" is the name of this timer, the 1.0f is how long the timer last's for, and "Timer_1" means that once the 1.0f is up, it will call the function "Timer_1". (Note: you can put how ever long you want for the time, you don't always have to put the "f" in front of the time, but you should do it anyway just to be safe.) Now once we have done this, we need to make a timer function called "Timer_1" to tell the game once it is done with the timer we just made.
The script you will be using is this:
void Timer_1(string &in asTimer)
{
StopPlayerLookAt();
}
This means that when the timer is activated, it will stop the player looking at the script area.
All together it should look like this:
void OnStart()
{
AddEntityCollideCallback("Player" , "PLYAERLOOK" , "Look" , true , 1);
}
void Look(string &in asParent, string &in asChild, int alState)
{ StartPlayerLookAt("LOOK1", 6, 6, "notneededfortutorial");
AddTimer("look01", 1.0f, "Timer_1");
}
void Timer_1(string &in asTimer)
{
StopPlayerLookAt();
}
That's it