Example #1
0
    // Update is called once per frame
    void Update()
    {
        var turn = Input.GetAxis("Horizontal");

        walker_char.Move(Input.GetAxis("Vertical"), turn, Time.fixedDeltaTime, Input.GetButton("Jump"));

        // Get raw mouse input for a cleaner reading on more sensitive mice.
        var mouseDelta = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));

        // Scale input against the sensitivity setting and multiply that against the smoothing value.
        mouseDelta = Vector2.Scale(mouseDelta, new Vector2(sensitivity.x * smoothing.x, sensitivity.y * smoothing.y));

        // Interpolate mouse movement over time to apply smoothing delta.
        _smoothMouse.x = Mathf.Lerp(_smoothMouse.x, mouseDelta.x, 1f / smoothing.x);
        _smoothMouse.y = Mathf.Lerp(_smoothMouse.y, mouseDelta.y, 1f / smoothing.y);
        walker_char.Look(_smoothMouse.x, _smoothMouse.y);

        if (Input.GetKey(KeyCode.I))
        {
            floor.transform.eulerAngles = new Vector3(30, 0);
        }
        else if (Input.GetKey(KeyCode.K))
        {
            floor.transform.eulerAngles = new Vector3(-30, 0);
        }
        else if (Input.GetKey(KeyCode.J))
        {
            floor.transform.eulerAngles = new Vector3(0, 0, 30);
        }
        else if (Input.GetKey(KeyCode.L))
        {
            floor.transform.eulerAngles = new Vector3(0, 0, -30);
        }
        else
        {
            floor.transform.eulerAngles = Vector3.zero;
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            walker_char.state.accel.y += 100;
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (cam_is_static)
            {
                attach_cam_to_walker(walker_char);
            }
            else
            {
                cam.transform.position    = side_spot.transform.position;
                cam.transform.eulerAngles = new Vector3(0, 90, 0);
                cam.transform.SetParent(side_spot.transform);
            }
            cam_is_static = !cam_is_static;
        }
    }
Example #2
0
    private void FixedUpdate()
    {
        var turn = Input.GetAxis("Horizontal");

        walker_char.Move(Input.GetAxis("Vertical"), turn, Time.fixedDeltaTime, Input.GetButton("Jump"));
        walker_char.energy_update(Time.fixedDeltaTime * Game.AVARA_FPS);
        ai3d.energy_update(Time.fixedDeltaTime * Game.AVARA_FPS);
        // Get raw mouse input for a cleaner reading on more sensitive mice.
        var mouseDelta = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));

        // Scale input against the sensitivity setting and multiply that against the smoothing value.
        mouseDelta = Vector2.Scale(mouseDelta, new Vector2(sensitivity.x * smoothing.x, sensitivity.y * smoothing.y));

        // Interpolate mouse movement over time to apply smoothing delta.
        _smoothMouse.x = Mathf.Lerp(_smoothMouse.x, mouseDelta.x, 1f / smoothing.x);
        _smoothMouse.y = Mathf.Lerp(_smoothMouse.y, mouseDelta.y, 1f / smoothing.y);
        walker_char.Look(_smoothMouse.x, _smoothMouse.y);
    }