void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Wall" && bouncing < maxBouncing) { ContactPoint cp = collision.contacts[0]; //rigidbody.velocity = Vector3.Reflect(rigidbody.velocity,collision.collider.transform.position.normalized); rigidbody.velocity = Vector3.Reflect(rigidbody.velocity, cp.normal) * 2; bouncing++; } else { if (collision.gameObject.GetComponent <CarStatus>() != null) { CarStatus car = collision.gameObject.GetComponent <CarStatus>(); car.infligerDegat(damage); } GameObject prefabExplosion = Resources.Load("Explosion") as GameObject; ExplosionPhysicsForce epf = prefabExplosion.GetComponent <ExplosionPhysicsForce>(); epf.explosionForce = 1; prefabExplosion.transform.position = this.transform.position; GameObject explosion = Instantiate(prefabExplosion) as GameObject; GameObject.Destroy(this.gameObject); GameObject.Destroy(explosion, 3); } }
void OnCollisionEnter(Collision collision) { Debug.Log("Collision Proj"); if (collision.gameObject.tag == "Wall") { Explosion(); } else { if (collision.gameObject.GetComponent <CarStatus> () != null) { CarStatus car = collision.gameObject.GetComponent <CarStatus> (); car.infligerDegat(damage); } Explosion(); } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.GetComponent <CarController>() != null) { CarController carcontroller = collision.gameObject.GetComponent <CarController>(); Explosion(); if (carcontroller == firstPlayerTarget) { GameObject.Destroy(this.gameObject); } } if (collision.gameObject.GetComponent <CarStatus>() != null) { CarStatus carStatus = collision.gameObject.GetComponent <CarStatus>(); carStatus.infligerDegat(damage); } }
// Entre dans cette fonction lorsqu il y a une collision void OnCollisionEnter(Collision collision) { if (collision.gameObject.GetComponent <CarStatus>()) { CarStatus car = collision.gameObject.GetComponent <CarStatus>(); if (explode) { GameObject prefabExplosion = Resources.Load("Explosion") as GameObject; ExplosionPhysicsForce epf = prefabExplosion.GetComponent <ExplosionPhysicsForce>(); epf.explosionForce = explosionForce; car.transform.position = this.transform.position; GameObject explosion = Instantiate(prefabExplosion) as GameObject; GameObject.Destroy(explosion, 3); } if (destructible) { GameObject.Destroy(this.gameObject); } car.infligerDegat(damage); } }