Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (holdingBall)
     {
         Ball.transform.position = PlayerCamera.transform.position + PlayerCamera.transform.forward * ballDistance;
         if (Input.GetMouseButtonDown(0))
         {
             Ball.ActivateTrail();
             holdingBall = false;
             Ball.GetComponent <Rigidbody>().useGravity = true;
             Ball.GetComponent <Rigidbody>().AddForce(PlayerCamera.transform.forward * ballThrowingForce);
         }
     }
 }
Exemple #2
0
 // Update is called once per frame
 public void FixedUpdate()
 {
     if (isholdingBall)
     {
         ball.transform.position = playerCamera.transform.position + playerCamera.transform.forward * distanceToBall;
         //The basketball is thrown when the player clicked the mouse button.
         if (Input.GetMouseButtonDown(0))
         {
             isholdingBall = false;
             ball.ActivateTrail();
             ball.GetComponent <Rigidbody>().useGravity = true;
             ball.GetComponent <Rigidbody>().AddForce(playerCamera.transform.forward * ballThrowingForce);
         }
     }
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (holdingBall)
        {
            ball.transform.position = playerCamera.transform.position + playerCamera.transform.forward * ballDistance;  // position references point in the world; forward references the direction i.e up down left right;

            if (Input.GetMouseButton(0))
            {
                holdingBall = false;                                                                          // release ball
                ball.ActivateTrail();
                ball.GetComponent <Rigidbody>().useGravity = true;                                            // ball drops;

                ball.GetComponent <Rigidbody>().AddForce(playerCamera.transform.forward * ballThrowingForce); // throw
            }
        }
    }
Exemple #4
0
    void Update()
    {
        if (HoldingBall)
        {
            //Forward is always one WU from the origin
            ball.transform.position = playerCamera.transform.position + (playerCamera.transform.forward * ballDistance);

            if (Input.GetMouseButtonDown(0))
            {
                HoldingBall = false;
                ball.ActivateTrail();

                ball.GetComponent <Rigidbody>().useGravity = true;

                //Add force in a direction Vector3
                ball.GetComponent <Rigidbody>().AddForce(playerCamera.transform.forward * throwingForce);
            }
        }
    }
Exemple #5
0
 public void thro()
 {
     ball.ActivateTrail();
     ball.GetComponent <Rigidbody>().useGravity = true;
     ball.GetComponent <Rigidbody>().AddForce(playerCamera.transform.forward * ballThrowingForce);
 }