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.
Here you can find answered ScriptAPI topics.
-
Ol1vver
- 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 » 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
Code: Select all
IObjectTimerTrigger CheckTimer;
IObjectTrigger Stop;
IObjectTrigger Left;
IObjectTrigger Right;
public void OnStartup()
{
CheckTimer = Game.GetSingleObjectByCustomID("Checker") as IObjectTimerTrigger;
Stop = Game.GetSingleObjectByCustomID("Stop") as IObjectTrigger;
Left = Game.GetSingleObjectByCustomID("Left") as IObjectTrigger;
Right = Game.GetSingleObjectByCustomID("Right") as IObjectTrigger;
CheckTimer.Trigger();
}
public void CheckPlayers(TriggerArgs args)
{
foreach(IPlayer ply in Game.GetPlayers())
{
if(ply.IsIdle)
{
Stop.Trigger();
}
if(ply.IsRunning)
{
Left.Trigger();
}
if(ply.IsRunning)
{
Right.Trigger();
}
}
}
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
-
Sree
- 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
-
Ol1vver
- 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
-
Sree
- 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
-
Pricey
- 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
-
Ol1vver
- 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