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
How to make someone look somewhere for a specified time.
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#1
How to make someone look somewhere for a specified time.

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"):


.jpg   1-1.jpg (Size: 103.62 KB / Downloads: 236)


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 itSmile


Attached Files
.jpg   1.jpg (Size: 100.04 KB / Downloads: 182)

(This post was last modified: 12-04-2011, 10:44 AM by flamez3.)
10-25-2011, 11:52 AM
Find
BesTCracK Offline
Member

Posts: 60
Threads: 14
Joined: Nov 2011
Reputation: 0
#2
RE: How to make someone look somewhere for a specified time.

Well it works good but when I make the potion from the two potions I want that potion I MADE to use for next combine with OTHER potion to again make new one , how the script have to look like ? Tongue
This text joins to this Big Grin http://www.frictionalgames.com/forum/thread-11653.html
(This post was last modified: 12-05-2011, 07:30 PM by BesTCracK.)
12-05-2011, 07:29 PM
Find
Gamemakingdude Offline
Senior Member

Posts: 470
Threads: 82
Joined: Nov 2010
Reputation: 9
#3
RE: How to make someone look somewhere for a specified time.

Wrong sectiong BesTCracK go post in Development support.

Rep if like me or im helpful or you love my stories!
Stephanos house
12-06-2011, 12:30 AM
Find




Users browsing this thread: 1 Guest(s)