private void Awake() { #if DEBUG Debug.Assert(m_instance == null, "The InputController may only exist once."); #endif m_instance = this; m_currentInputFrame = new common.data.InputFrame(); m_controls = new PlayerControls(); m_controls.Gameplay.Move.performed += context => MoveCharacter(context.ReadValue <Vector2>()); m_controls.Gameplay.Move.canceled += context => MoveCharacter(Vector2.zero); m_controls.Gameplay.Sprint.performed += context => SetSprinting(true); m_controls.Gameplay.Sprint.canceled += context => SetSprinting(false); }
/// <summary> /// Stores the client state in local storage and updates it. /// </summary> /// <param name="state">State to store and update</param> /// <param name="input">Input used to step state simulation</param> /// <param name="deltaTime"></param> public abstract void SetStateAndStep(ref ClientState state, common.data.InputFrame input, float deltaTime);
static public void Execute(ref Rigidbody2D rigidbody, gameplay.PlayerStats stats, common.data.InputFrame input, float deltaTime) { rigidbody.velocity = input.Movement.Value * stats.WalkingVelocity.Value * (input.Sprinting.Value ? stats.RunningMultiplier.Value : 1f); }