Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        if (_grounded)
        {
            if (_jsc.GetJoystickActive())
            {
                Vector3 camForward = _mainCamera.transform.forward;
                Vector3 camRight   = _mainCamera.transform.right;
                camForward.y = 0f;
                camRight.y   = 0f;
                camForward   = camForward.normalized;
                camRight     = camRight.normalized;

                Vector3 vel = ((camForward * _jsc.inputDirection.y + camRight * _jsc.inputDirection.x) * speed * Time.deltaTime);
                _rb.velocity = vel;
                Debug.Log("velocity vector:" + vel);
            }
            else
            {
                _rb.velocity = Vector3.zero;
            }
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(this.transform.position, Vector3.down, out hit, (this.transform.localScale.y / 2 + 0.05f)))
            {
                if (hit.transform.gameObject.tag == "Arena")
                {
                    _grounded = true;
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void FixedUpdate()
    {
        //if (_grounded)
        if (_jsc.GetJoystickActive())
        {
            Vector3 camForward = _ARCamera.transform.forward;
            Vector3 camRight   = _ARCamera.transform.right;
            camForward.y = 0f;
            camRight.y   = 0f;
            camForward   = camForward.normalized;
            camRight     = camRight.normalized;

            moveDirection = ((camForward * _jsc.inputDirection.y + camRight * _jsc.inputDirection.x) * _speed * Time.deltaTime);
            _rb.velocity  = moveDirection;
            //_CharController.Move(vel);
        }
        else
        {
            moveDirection = Vector3.zero;
            _rb.velocity  = moveDirection;
            //_CharController.Move(Vector3.zero);
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        Debug.Log("Grounded:" + characterController.isGrounded);
        if (characterController.isGrounded)
        {
            // We are grounded, so recalculate
            // move direction directly from axes
            if (_jsc.GetJoystickActive())
            {
                Vector3 camForward = _ARCamera.transform.forward;
                Vector3 camRight   = _ARCamera.transform.right;
                camForward.y = 0f;
                camRight.y   = 0f;
                camForward   = camForward.normalized;
                camRight     = camRight.normalized;

                moveDirection = ((camForward * _jsc.inputDirection.y + camRight * _jsc.inputDirection.x) * speed * Time.deltaTime);
                Debug.Log("moveDir: " + moveDirection);
            }
            else
            {
                moveDirection = Vector3.zero;
            }
            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }

        // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
        // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
        // as an acceleration (ms^-2)
        moveDirection.y -= gravity * Time.deltaTime;

        // Move the controller
        characterController.Move(moveDirection * Time.deltaTime);
    }