public void OnCollisionEnter(Collision c) { if (c.gameObject.tag == "Player" && justHit == false) { if (notHit) { CreditManager.victimNumbers.Add(1); notHit = false; } ouch.Play(); GoingOffRoadDemeritCounter.setDemerits(20); float speed = bob.CurrentSpeed; GetComponent <CharacterController>().enabled = false; this.GetComponent <Animator>().enabled = false; GetComponent <rotate180>().enabled = false; GetComponent <CapsuleCollider>().enabled = false; GetComponent <Rigidbody>().isKinematic = false; GetComponent <Rigidbody>().AddForce(bob.transform.forward * (speed)); GetComponent <Rigidbody>().useGravity = true; GetComponent <CapsuleCollider>().enabled = true; StartCoroutine(flashTime(3, PedHit)); //Change the first parameter of flashTime to change the amount of time the text is on. StartCoroutine(hitTime()); } }
public void OnCollisionEnter(Collision c) { if (c.gameObject.tag == "Player" && justHit == false) { if (notHit) { CreditManager.victimNumbers.Add(5); notHit = false; } ouch.Play(); GoingOffRoadDemeritCounter.setDemerits(20); // THIS IS WHERE TO ADD PEDESTRIAN PHYSICS // (1) Stop 'walking' Animation from playing // switch to idle "default" mode // just add a condition in transitions // in animator window // (2) Get the direction of where pedestrian was hit ..? // this would be 'transform.forward' below ....? // (3) Apply force to pedestrian (need rigidbody component for this part) //GetComponent<Rigidbody>().AddForce(transform.forward * 500); //GetComponent<Rigidbody>().useGravity = true; ////////////////////////////////////////// StartCoroutine(flashTime(3, PedHit)); //Change the first parameter of flashTime to change the amount of time the text is on. StartCoroutine(hitTime()); } }
public void OnCollisionEnter(Collision c) { if (c.gameObject.tag == "Player" && justHit == false) { GoingOffRoadDemeritCounter.setDemerits(20); StartCoroutine(flashTime(3, PedHit)); //Change the first parameter of flashTime to change the amount of time the text is on. StartCoroutine(hitTime()); } }
public void OnCollisionEnter(Collision c) { if (c.gameObject.tag == "Player" && justHitCar == false) { if (notHit) { CreditManager.victimNumbers.Add(3); notHit = false; } crash.Play(); GoingOffRoadDemeritCounter.setDemerits(10); StartCoroutine(flashTime(3, CarHit)); //Change the first parameter of flashTime to change the amount of time the text is on. StartCoroutine(hitTimeCar()); } }