Hello, was wondering why this doesn’t work.
Here’s the script.
SpriteRenderer spritegira;
void Flip()
{
if (corpo.velocity.x < 0 )
{
spritegira.flipX = true;
//CmdDirectionChange(-1);
if (!isLocalPlayer)
{
CmdDirectionChange(-1);
}
if (!isServer)
{
CmdDirectionChange(-1);
}
}
if (corpo.velocity.x > 0)
{
//CmdDirectionChange(1);
spritegira.flipX = false;
if(!isLocalPlayer)
{
CmdDirectionChange(1);
}
if (!isServer)
{
CmdDirectionChange(1);
}
}
}
[Command]
void CmdDirectionChange(int direction)
{
if (direction == 1)
{
spritegira.flipX = false;
}
if (direction == -1)
{
spritegira.flipX = true;
}
}