server trigger onAttach. IsControl == false

Options
hi!

I want server create player. OnAttach isControl = false. I want isControl true.


BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.Player,
            new Vector3(0, 1, 0),
            Quaternion.identity);
        
        if (evnt.RaisedBy == null){     //server ,  isControl = false?  I want to set it to true. trigger OnAttach
            entity.TakeControl();
            entity.AssignControl(BoltNetwork.Server);
            Debug.Log("手动触发");
            BoltNetwork.Attach(entity.gameObject);          //isControl = false.  I don't know write code
        }else
            entity.AssignControl(evnt.RaisedBy); //client isControl = true. No problem










Comments

  • stanchion
    Options
    You need to wait a frame for control to update. You should only Take or Assign control, depending if you are the host or not.
  • plateface
    Options
    stanchion wrote: »
    You need to wait a frame for control to update. You should only Take or Assign control, depending if you are the host or not.

    Thanks。 I write Invoke("Init",0.1f);
This discussion has been closed.