using UnityEngine; using UnityEngine.InputSystem; namespace Game { public class RealPlayer : Player { public bool isThisClient; private new void Start() { base.Start(); GameUI.Singleton.buttonDown += (side, direction) => { if (!side.Equals(Side)) return; if (direction == "left") goingLeft = true; else goingRight = true; }; GameUI.Singleton.buttonUp += (side, direction) => { if (!side.Equals(Side)) return; if (direction == "left") goingLeft = false; else goingRight = false; }; } private void FixedUpdate() { if (!isThisClient) return; if (Application.isEditor) { var keyboard = Keyboard.current; switch (Side) { case Side.Top: goingLeft = keyboard.aKey.isPressed; goingRight = keyboard.dKey.isPressed; break; case Side.Bottom: goingLeft = keyboard.leftArrowKey.isPressed; goingRight = keyboard.rightArrowKey.isPressed; break; } } TryLinearMove(Time.fixedDeltaTime); } } }