Client can not move its own player

Options

I tried to change the position and value of player.

Only the host can move all players, the clients can not move its own player.

Here is what my player looks like

The following the the script of player


 public class PlayerCtrl : NetworkBehaviour

  {

    // Start is called before the first frame update

    private TMP_Text info;


    [Networked] private int life { get; set; }

    [Networked] private float movex { get; set; } = 0;

    [Networked] private float movey { get; set; } = 0;


    void Awake()

    {

      info = transform.Find("empty").Find("Info").GetComponent<TMP_Text>();

    }

  

    public override void Spawned()

    {

      life = Random.Range(0,100);

    }


    private void Update()

    {

      if (Object.HasStateAuthority)

      {

        if (Input.GetKeyDown(KeyCode.Equals))

          life += 1;

        if (Input.GetKeyDown(KeyCode.Minus))

          life -= 1;


        movex = Input.GetAxis("Horizontal") * Runner.DeltaTime * 5;

        movey = Input.GetAxis("Vertical") * Runner.DeltaTime * 5;

      }

    }


    public override void FixedUpdateNetwork()

    {


      transform.position += new Vector3(movex, movey, 0);

      info.text = life + "";


    }

  }

Answers

  • Luke_Sta
    Options

    Please follow the Fusion-100 series or anther tutorial to learn Fusion. Your approach does not work with Fusion.

  • xactbupt
    Options

    Thanks, I tried the examples in Fusion-100, and just want to explore other possible solutions.