Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.5 kB
6
Indexable
Never
    PlayerAnimator.cs    

    public void Look(Vector2 lookAxis, float deltaTime)
    {
        if (canLookAway)
        {
            input = lookAxis;

            float deltaMouseX = -input.x * sensitivity * deltaTime;
            float deltaMouseY = -input.y * sensitivity * deltaTime;

            _playerInput.x += deltaMouseX;
            _playerInput.y += deltaMouseY;

            _playerInput.x = Mathf.Clamp(_playerInput.x, -90f, 90f);
            _playerInput.y = Mathf.Clamp(_playerInput.y, -90f, 90f);

            _charAnimData.deltaAimInput = new Vector2(deltaMouseX, deltaMouseY);

            Debug.Log(deltaMouseX);

            transform.Rotate(Vector3.up * deltaMouseX);
        }
    }


    PlayerInputProvider.cs

    private void Update()
    {
        pendingJump |= Input.GetKeyDown(KeyCode.Space);

        input.forward = (int) prevoriusInput.y;
        input.right = (int) prevoriusInput.x;

        input.lookX = prevoriusLook.x;
        input.lookY = prevoriusLook.y;
    }

    Input that I'm sending over network

    public struct PlayerInput : PRN.IInput
    {
    public float lookX;
    public float lookY;
    public int tick;
    public int forward;
    public int right;
    public bool jump;
    public bool crouch;
    public bool run;

    // You need to implement those 2 methods
    public void SetTick(int tick) => this.tick = tick;
    public int GetTick() => tick;
    }
Leave a Comment