Hey guys! I'm new with the Unity2D networking, and I have a trouble with the movement. There are two simple moving players, in one server, the moving got messed up, and if i move my player right, the other client moves to the right. There is my movement script: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class playerManager : MonoBehaviour { private bool isGrounded; public Transform feetPos; public float checkRadius; public LayerMask whatIsGround; public float jumpForce; private Rigidbody2D myRigidbody; [SerializeField] private float movementSpeed; void Start() { myRigidbody = GetComponent<Rigidbody2D>(); } void Update() { isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround); if(isGrounded == true && Input.GetKeyDown(KeyCode.Space)) { myRigidbody.velocity = Vector2.up * jumpForce; } } void FixedUpdate() { float horizontal = Input.GetAxisRaw("Horizontal"); HandleMovement(horizontal); } private void HandleMovement(float horizontal) { myRigidbody.velocity = new Vector2(horizontal * movementSpeed,myRigidbody.velocity.y); } } I got a NetworkManager GameObject with NetworkManager and NetworkManagerHUD components in it. And in the player prefab, there is a NetworkIdentity and a NetworkTransform. I set in the "Local Player Authorit" in my player. So help me! Why the other clients moving with me? How can I fix it?
In Update you are not checking if this script is attached to the correct player before checking input and applying velocity. Update, FixedUpdate, etc, will run on the server and all clients for all of the gameobjects in the scene, including objects for players that represent other clients.
I think you do something like this Code (CSharp): if (!isLocalPlayer) return; HandleMovement(horizontal);