void AttemptAttack() { nextAttack = Time.time + attackRate; timer = 0f; if (gunMaster.isGunLoaded) { //Debug.Log ("Shooting"); gunMaster.CallEventPlayerInput(); gunLine.enabled = true; gunLine.SetPosition(0, transform.position); shootRay.origin = transform.position; shootRay.direction = transform.parent.forward; if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { // Set the second position of the line renderer to the point the raycast hit. gunLine.SetPosition(1, shootHit.point); } // If the raycast didn't hit anything on the shootable layer... else { // ... set the second position of the line renderer to the fullest extent of the gun's range. gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } } else { gunMaster.CallEventGunNotUsable(); } }
public void AttemptAttack() { if (gunMaster.isGunLoaded) { //Debug.Log ("Shooting"); gunMaster.CallEventPlayerInput(); } else { gunMaster.CallEventGunNotUsable(); } }
void AttemptAttack() { nextAttack = Time.time + attackRate; if (gunMaster.isGunLoaded) { gunMaster.CallEventPlayerInput(); } else { gunMaster.CallEventGunNotUsuable(); } }
void AttemptAttack() { nextAttack = Time.time + attackRate; if (gunMaster.isGunLoaded) { //Debug.Log("Shooting"); gunMaster.CallEventPlayerInput(); } else { gunMaster.CallEventGunNotUsable(); } }
void AttemptAttack() { nextAttack = Time.time + attackRate; timer = 0f; if (gunMaster.isGunLoaded) { //Debug.Log ("Shooting"); gunMaster.CallEventPlayerInput(); gunLine.enabled = true; gunLine.SetPosition(0, transform.position); shootRay.origin = transform.position; shootRay.direction = transform.parent.forward; GameObject go = (GameObject)Instantiate(grenadePrefab, myTransform.TransformPoint(0, 0, 0f), myTransform.rotation); go.GetComponent <Rigidbody> ().AddForce(myTransform.parent.forward * propulsionForce, ForceMode.Impulse); Destroy(go, 10); if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { // Set the second position of the line renderer to the point the raycast hit. gunLine.SetPosition(1, shootHit.point); } // If the raycast didn't hit anything on the shootable layer... else { // ... set the second position of the line renderer to the fullest extent of the gun's range. gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } } else { gunMaster.CallEventGunNotUsable(); } }