Exemple #1
0
    private void Shoot(float velocity)
    {
        Debug.Log("Shooting!!!");

        pullHand.ReleaseArrow();
        attachedArrow.transform.parent = null;

        attachedArrow.ArrowReleased(velocity * velocityMultiplier);

        stringAttachPoint.position = stringStartPoint.position;
        attachedArrow = null;
    }
    //Old gun firing method goes to sleep... zzz mr gun method!

    /*private void Fire ()
     * {
     *  if (!canFire)
     *      return;
     *
     *          Debug.DrawRay(firingTrans.position, firingTrans.forward * 10000f, Color.red, 5f);
     *
     *          //FIXME model color changes not working after models integrated
     *  RaycastHit hit;
     *  if (Physics.Raycast(firingTrans.position, firingTrans.forward, out hit)) {
     *                  if (hit.transform == apple) {
     *                          Debug.Log("Apple core!");
     *                          PlayerController.Instance.vrInstructionText.text = "HE SHOT THE APPLE!!!";
     *                          PlayerController.Instance.externalMonitorText.text = "YOU SHOT THE APPLE!!!!";
     *                          PlayerController.Instance.vrInstructionText.enabled = true;
     *                          PlayerController.Instance.externalMonitorText.enabled = true;
     *                  } else if (hit.transform == head) {
     *                          Debug.LogError("You shot your son!!!");
     *                          PlayerController.Instance.vrInstructionText.text = "YOU'RE DEAD!!!!";
     *                          PlayerController.Instance.externalMonitorText.text = "YOU SHOT HIM YOU MONSTER!!!!!!";
     *                          PlayerController.Instance.vrInstructionText.enabled = true;
     *                          PlayerController.Instance.externalMonitorText.enabled = true;
     *                  }
     *                  PlayerController.Instance.EndGame();
     *  }
     * }*/

    private void ShootArrow()
    {
        Shots--;
        animator.Play("Shoot");
        arrow.shaftRB.isKinematic = false;
        arrow.shaftRB.useGravity  = true;
        arrow.shaftRB.transform.GetComponent <BoxCollider>().enabled = true;

        arrow.arrowHeadRB.isKinematic = false;
        arrow.arrowHeadRB.useGravity  = true;
        arrow.arrowHeadRB.transform.GetComponent <BoxCollider>().enabled = true;
        arrow.transform.parent = null;
        arrow.ArrowReleased(ArrowReleaseVelocity);

        arrow.arrowHeadRB.AddForce(arrow.transform.forward * ArrowReleaseVelocity, ForceMode.VelocityChange);
        arrow.arrowHeadRB.AddTorque(arrow.transform.forward * 10f);
        arrow = null;
    }