// Update is called once per frame
    void Update()
    {
        if (throwWeapon)
        {
            combat.Charge();
        }
        if (oldThrowWeapon == true && throwWeapon == false)
        {
            //Throw towards target
        }

        if (dropWeapon)
        {
            combat.Drop();
        }

        if (target)
        {
            if (Mathf.Abs(turnSpeed) < 1)
            {
                moveSpeed = 1;
            }
            else
            {
                moveSpeed = 0.5f;
            }

            Vector3 targetDir = target.position - transform.position;
            float   angle     = Vector3.Angle(targetDir, transform.forward);
        }
        else
        {
            moveSpeed = 1;
        }

        movement.turn   = turnSpeed;
        movement.thrust = moveSpeed;

        oldThrowWeapon = throwWeapon;
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        lookDirection = new Vector3(Input.GetAxis("LookHorizontal" + playerControlString), Input.GetAxis("LookVertical" + playerControlString), 0);

        if (Input.GetButtonDown("Boost" + playerControlString))
        {
            movement.boosting = true;
        }
        if (Input.GetButtonUp("Boost" + playerControlString))
        {
            movement.boosting = false;
        }

        if (Input.GetButtonDown("Drift" + playerControlString))
        {
            movement.drifting = true;
        }
        if (Input.GetButtonUp("Drift" + playerControlString))
        {
            movement.drifting = false;
        }
        //Keyboard Fire mechanism
        if (Input.GetButtonDown("Fire" + playerControlString))
        {
            if (controlType == ControlType.Keyboard)
            {
                combat.Charge();
            }
            else
            {
                RaycastHit hit;
                target = Vector3.zero;
                Vector3 direction = new Vector3(lookDirection.x, 0, lookDirection.y) * 10.0f;
                Physics.Raycast(transform.position + direction + Vector3.up * 50, Vector3.down, out hit, 1000, obstacleMask);
                target    = hit.point;
                target.y += 1;
                combat.Attack(target);
                charging = false;
            }
        }
        if (Input.GetButtonUp("Fire" + playerControlString))
        {
            if (controlType == ControlType.Keyboard)
            {
                RaycastHit hit;
                target = Vector3.zero;
                Physics.Raycast(myCamera.ScreenPointToRay(Input.mousePosition), out hit, 1000, obstacleMask);
                Debug.Log(hit.point);
                target    = hit.point;
                target.y += 1;
                //target.y = transform.position.y;
                combat.Attack(target);
            }
        }

        if (lookDirection.magnitude > 0 && !charging)
        {
            combat.Charge();
            charging = true;
        }
        else if (lookDirection.magnitude < 0.1f)
        {
            charging = false;
        }

        if (Input.GetButtonDown("Drop" + playerControlString))
        {
            combat.Drop();
        }

        movement.turn   = Input.GetAxis("Horizontal" + playerControlString);
        movement.thrust = Input.GetAxis("Vertical" + playerControlString);

        if (lookDirection.magnitude > 0.5f)
        {
            Vector3 targetDir = Vector3.RotateTowards(aimReticle.forward, new Vector3(-lookDirection.x, 0, -lookDirection.y), 1.0f, 0.0f);
            aimReticle.rotation = Quaternion.LookRotation(targetDir);
            reticleRend.enabled = true;
        }
        else
        {
            reticleRend.enabled = false;
        }

        lastLookDirection = lookDirection;
    }