// Update is called once per frame void Update() { if (holdingBasketball) { basketball.transform.position = this.transform.position + this.transform.forward * basketballDistance + basketballOffset; basketball.GetComponent <Rigidbody> ().useGravity = false; if (calculatingShot) { shootingTimer += Time.deltaTime; } if (GvrViewer.Instance.Triggered || Input.GetKeyDown("space")) { if (calculatingShot == false) { calculatingShot = true; } else if (holdingBasketball) { holdingBasketball = false; basketball.GetComponent <Rigidbody> ().useGravity = true; float calculatedScale = Mathf.Min(shootingTimer, 1f); float calculatedForce = minimumShootingForce + (maximumShootingForce - minimumShootingForce) * calculatedScale; basketball.GetComponent <Rigidbody> ().AddForce(this.transform.forward * calculatedForce); } } } }
public void PickBasketball() { holdingBasketball = true; basketball.hitSomething = false; basketball.GetComponent <Rigidbody> ().velocity = Vector3.zero; basketball.GetComponent <Rigidbody> ().angularVelocity = Vector3.zero; }
// Start is called before the first frame update void Start() { player = GameObject.Find("Player").GetComponent <Player>(); basketball = GameObject.Find("Basketball").GetComponent <Basketball>(); Debug.Log(basketball == null); basketballRigidbody = basketball.GetComponent <Rigidbody>(); playerCamera = GameObject.Find("FirstPersonCharacter"); resetTimerInitial = 10.0f; resetTimer = resetTimerInitial; resetGame = false; pauseTimer = false; player.InitializeObjects(); }