Client can not move its own player
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Client can not move its own player
xactbupt
2022-08-20 06:46:57
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 + "";
}
}
Comments
Please follow the Fusion-100 series or anther tutorial to learn Fusion. Your approach does not work with Fusion.
Thanks, I tried the examples in Fusion-100, and just want to explore other possible solutions.
Back to top