Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

How to get a player's FacingDirection?

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

How to get a player's FacingDirection?

Post by Ol1vver » Thu Dec 27, 2018 5:43 pm

Hello,
How do I get the FacingDirection of a player?
I don't know how, even though it seemed simple.
Here's the script I have right now:
► Show Spoiler
I also would like some help to make the controls host-only, or make some other separated controls for a second player (or more).
0 x

User avatar
Sree
Superfighter
Superfighter
Posts: 325
Joined: Sun May 08, 2016 8:19 pm
SFD Account: phasmic
SFD Alias: sree
Gender:
Age: 23

Post by Sree » Thu Dec 27, 2018 9:13 pm

ply.FacingDirection property will either return 1 or -1, 1 for right and -1 for left.
0 x

User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Post by Ol1vver » Fri Dec 28, 2018 6:40 pm

Sree wrote:
Thu Dec 27, 2018 9:13 pm
ply.FacingDirection property will either return 1 or -1, 1 for right and -1 for left.
But how to use it?
How do I get the number and use it to get the player's FacingDirection?
0 x

User avatar
Sree
Superfighter
Superfighter
Posts: 325
Joined: Sun May 08, 2016 8:19 pm
SFD Account: phasmic
SFD Alias: sree
Gender:
Age: 23

Post by Sree » Fri Dec 28, 2018 7:32 pm

Ol1vver wrote:
Fri Dec 28, 2018 6:40 pm
How do I get the number and use it to get the player's FacingDirection?
I'm pretty sure I've already answered those..
1 x

User avatar
Pricey
Superfighter
Superfighter
Posts: 399
Joined: Thu May 05, 2016 9:29 pm
SFD Alias: (LM) Pricey
Started SFD: August 2015
Location: United Kingdom
Gender:
Age: 22

Post by Pricey » Fri Dec 28, 2018 7:40 pm

Change if(ply.IsRunning) to if(ply.IsRunning && ply.FacingDirection < 0) to check if they’re facing left, and > 0 to check if they’re facing right.
1 x

User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Post by Ol1vver » Sat Dec 29, 2018 4:33 pm

Pricey wrote:
Fri Dec 28, 2018 7:40 pm
Change if(ply.IsRunning) to if(ply.IsRunning && ply.FacingDirection < 0) to check if they’re facing left, and > 0 to check if they’re facing right.
Thanks!

Nevermind, that didn't work. It keeps showing me an error that it doesn't exist..

Nevermind, I just misspelled it.
0 x

Post Reply