Page 1 of 1
How to get a player's FacingDirection?
Posted: Thu Dec 27, 2018 5:43 pm
by Ol1vver
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).
Re: How to get a player's FacingDirection?
Posted: Thu Dec 27, 2018 9:13 pm
by Sree
ply.FacingDirection property will either return 1 or -1, 1 for right and -1 for left.
Re: How to get a player's FacingDirection?
Posted: Fri Dec 28, 2018 6:40 pm
by Ol1vver
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?
Re: How to get a player's FacingDirection?
Posted: Fri Dec 28, 2018 7:32 pm
by Sree
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..
Re: How to get a player's FacingDirection?
Posted: Fri Dec 28, 2018 7:40 pm
by Pricey
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.
Re: How to get a player's FacingDirection?
Posted: Sat Dec 29, 2018 4:33 pm
by Ol1vver
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.