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
Force player to look somewhere
naseem142 Offline
Member

Posts: 153
Threads: 19
Joined: Oct 2012
Reputation: 0
#1
Force player to look somewhere

First of all , i'm really sorry for flooding with help topics . This is my last one! Confused

I need help to force look the player somewhere on the map when touching a script area , there is already one which makes you look somewhere but it is triggered instantly when you enter a map , so i tried to make it trigger when touching the script area but i failed pathetically. Sad
So please help?
10-12-2012, 01:26 PM
Website Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: Force player to look somewhere

I'm not sure what you're trying to say.

1) You don't know HOW to make the player look at something?
2) It just doesn't work.

If 2 is the answer, post your script file.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
10-12-2012, 01:57 PM
Website Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#3
RE: Force player to look somewhere

I'll show an example, on how you can do it.

//Creating the function to call
First: Making the game call a function when the player enters a area.

// First function
First: When the player enters the area, i set the player inactive, so the that you can't move him around.
Second: After the players is set inactive, i make him look at a torch.
Third: I create a timer, that activates the player, so that him can move around again

//Second function
Activating the player

Here is the example:

void OnStart()
{
AddEntityCollideCallback("Player", "LookArea", "StareAtTourch", true, 1);
}


void StareAtTourch(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
StartPlayerLookAt("torch_static01_1", 6.0f, 10.0f, "");
AddTimer("activate_player", 3, "activateplayer");
}


void activateplayer(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
}

PS. 6.0f is the speed the camera turns around, and 10.0f is the maximum speed that the camera is aloud t oturn

CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 10-12-2012, 02:40 PM by Lizard.)
10-12-2012, 02:34 PM
Find
naseem142 Offline
Member

Posts: 153
Threads: 19
Joined: Oct 2012
Reputation: 0
#4
RE: Force player to look somewhere

(10-12-2012, 01:57 PM)Nemet Robert Wrote: I'm not sure what you're trying to say.

1) You don't know HOW to make the player look at something?
2) It just doesn't work.

If 2 is the answer, post your script file.
http://www.frictionalgames.com/forum/thread-5117.html


Force player to look somewhere by mastersmith98
Spoiler below!

StartPlayerLookAt(ScriptArea, viewacceleration, maxviewvelocity, onlook);
ScriptArea is the name of the area script you place in your map and where the player looks.
viewacceleration controls how fast the player looks.
maxviewvelocity controls the max speed the player looks.
onlook is a function you call when the player's view is centered on the target.
To stop the player from looking at a spot, call StopPlayerLookAt();
Example:
void TimerDoneLookAt(string &in asTimer)
{
StopPlayerLookAt();
}

//When player starts the level, make him look at this spot.
void OnStart()
{
// Function argument is empty since we don't want to call a function.
StartPlayerLookAt("AreaLookAt", 2, 2, "");

//Make the player look for 2.5 seconds
AddTimer("donelook", 2.5f, "TimerDoneLookAt");
}

(This post was last modified: 10-12-2012, 02:35 PM by naseem142.)
10-12-2012, 02:35 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#5
RE: Force player to look somewhere

But, what's your problem? It doesn't look, it doesn't stop looking?
Also, that's a good thread.

If you want it to stop looking, use

StopPlayerLookAt();

If you want it to look somewhere, it should be like this:


void OnStart ()
{
AddEntityCollideCallback("Player", "ScriptArea", "Lookat", true, 1);
}

void Lookat (string &in asParent, string &in asChild, int alState);
{
StartPlayerLookAt("AreaLookAt", 2, 2, "");
}

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-12-2012, 02:43 PM
Find
naseem142 Offline
Member

Posts: 153
Threads: 19
Joined: Oct 2012
Reputation: 0
#6
RE: Force player to look somewhere

(10-12-2012, 02:43 PM)The chaser Wrote: But, what's your problem? It doesn't look, it doesn't stop looking?
Also, that's a good thread.

If you want it to stop looking, use

StopPlayerLookAt();

If you want it to look somewhere, it should be like this:


void OnStart ()
{
AddEntityCollideCallback("Player", "ScriptArea", "Lookat", true, 1);
}

void Lookat (string &in asParent, string &in asChild, int alState);
{
StartPlayerLookAt("AreaLookAt", 2, 2, "");
}
The script is easy , but the timer stuff is just complicated for me. ( as a newbie it gave me a headache Undecided )
so i wont do it anymore , it wasn't necessary for my custom story though it was just a bonus. Shy
But since your here , can you help me with this door-slam script?
I have no idea whats wrong with it , it looks perfect!


( I cut it out of my script so i wont need to post everything else Smile )



Door name: doorman
Script area name: slamdoor


void OnStart()
{
AddEntityCollideCallback("Player", "doorman", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("doorman", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}
(This post was last modified: 10-12-2012, 02:55 PM by naseem142.)
10-12-2012, 02:53 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Force player to look somewhere

Do you get an error?
I would recommend using AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
or
AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);

And you haven't used timers before? I suggest you to check them out! Timers are pretty good to have in your custom stories...

Trying is the first step to success.
(This post was last modified: 10-12-2012, 03:02 PM by FlawlessHappiness.)
10-12-2012, 03:02 PM
Find
naseem142 Offline
Member

Posts: 153
Threads: 19
Joined: Oct 2012
Reputation: 0
#8
RE: Force player to look somewhere

(10-12-2012, 03:02 PM)beecake Wrote: Do you get an error?
I would recommend using AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
or
AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);

And you haven't used timers before? I suggest you to check them out! Timers are pretty good to have in your custom stories...
Nope i don't get any errors , the door just doesn't respond to the script area >:|
10-12-2012, 03:07 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#9
RE: Force player to look somewhere

You didn't "say" to the script the name of the script area, it should be like this:

void OnStart()

{

    AddEntityCollideCallback("Player", "slamdoor", "func_slam", true, 1);

}



void func_slam(string &in asParent, string &in asChild, int alState)

{

SetSwingDoorClosed("doorman", true, true);



PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);



PlaySoundAtEntity("", "react_scare", "Player", 0, false);



PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);



GiveSanityDamage(5.0f, true);

}

Always that it doesn't work is for the callback. Well, that's the normal issue.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-12-2012, 03:19 PM
Find
naseem142 Offline
Member

Posts: 153
Threads: 19
Joined: Oct 2012
Reputation: 0
#10
RE: Force player to look somewhere

(10-12-2012, 03:19 PM)The chaser Wrote: You didn't "say" to the script the name of the script area, it should be like this:

void OnStart()

{

    AddEntityCollideCallback("Player", "slamdoor", "func_slam", true, 1);

}



void func_slam(string &in asParent, string &in asChild, int alState)

{

SetSwingDoorClosed("doorman", true, true);



PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);



PlaySoundAtEntity("", "react_scare", "Player", 0, false);



PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);



GiveSanityDamage(5.0f, true);

}

Always that it doesn't work is for the callback. Well, that's the normal issue.
it worked , thank you Smile
10-12-2012, 04:28 PM
Website Find




Users browsing this thread: 4 Guest(s)