private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag.Contains("Destroy")) { Destroy(this.gameObject); } else if (collision.gameObject.tag.Contains("Field")) { timerSet = true; } else if (collision.gameObject.tag.Contains("Base Hit")) { Instantiate(point); this.gameObject.GetComponent <Collider>().enabled = false; Destroy(this.gameObject, 60); } else if (collision.gameObject.tag.Contains("Double")) { Instantiate(point); Instantiate(point); this.gameObject.GetComponent <Collider>().enabled = false; Destroy(this.gameObject, 60); } else if (collision.gameObject.tag.Contains("Triple")) { Instantiate(point); Instantiate(point); Instantiate(point); this.gameObject.GetComponent <Collider>().enabled = false; Destroy(this.gameObject, 60); } else if (collision.gameObject.tag.Contains("Homerun")) { Instantiate(point); Instantiate(point); Instantiate(point); Instantiate(point); this.gameObject.GetComponent <Collider>().enabled = false; Destroy(this.gameObject, 60); } else if (collision.gameObject.tag.Contains("Foul")) { Destroy(this.gameObject); } else if (collision.gameObject.tag.Contains("Out")) { Instantiate(owt); this.gameObject.GetComponent <Collider>().enabled = false; Destroy(this.gameObject, 60); } else { theBat = collision.gameObject.GetComponent <bat>(); this.gameObject.GetComponent <Rigidbody>().velocity = (theBat.velocity2 + -(this.gameObject.GetComponent <Rigidbody>().velocity)) * 2.8f; this.gameObject.GetComponent <Rigidbody>().useGravity = true; this.gameObject.GetComponent <TrailRenderer>().enabled = true; } }
void Start() { guiText.text = (timerTime.ToString("f0")); timerPositionDummy = GameObject.Find("timerPositionDummy"); batScript = GameObject.Find("batDummy").GetComponent <bat>(); int screenWidthX = Screen.width; int screenHeightY = Screen.height; Vector3 timerScoreGUIPos = Camera.main.WorldToScreenPoint(timerPositionDummy.transform.position); float timerScoreGUIPos_x = (timerScoreGUIPos.x / screenWidthX); float timerScoreGUIPos_y = (timerScoreGUIPos.y / screenHeightY); this.transform.position = new Vector3(timerScoreGUIPos_x, timerScoreGUIPos_y - 0.01f, 0); guiText.fontSize = (int)(Screen.width * 0.04f); }
// Use this for initialization void Start() { anim = this.GetComponent <Animator>(); batScript = GameObject.Find("batDummy").GetComponent <bat>(); }
void valueB(bat bt) { b = bt.a; // variable a from class bat. }