void OnCollisionEnter(Collision c) { ContactPoint cp = c.contacts[0]; transform.up = cp.normal; transform.localScale = new Vector3(1.5f, 0.5f, 1); ShakeController shake = Camera.main.gameObject.GetComponent <ShakeController>(); shake.Shake(); if (c.gameObject.tag == "Player") { sound.clip = hitPaddle; sound.Play(); } else if (c.gameObject.tag == "Brick") { sound.clip = hitBrick; sound.Play(); } else { sound.clip = hitWall; sound.Play(); } ParticleSystem hitParticles = null; for (int i = 0; i < particlePool.Count; i++) { ParticleSystem p = particlePool[i]; if (p.isStopped) { hitParticles = p; Debug.Log("reusing from my pool"); break; } } if (hitParticles == null) { hitParticles = Instantiate(hitParticlesPrefab) as ParticleSystem; particlePool.Add(hitParticles); } ParticleSystem a = (c.gameObject.tag == "Player") ? paddle : hitParticles; //hitParticles.Stop(); //hitParticles.transform.position = transform.position; //hitParticles.transform.up = body.velocity; //hitParticles.Play(); a.Stop(); a.transform.position = transform.position; a.transform.up = body.velocity; a.Play(); }
void CameraShake() { ShakeController shake = Camera.main.gameObject.GetComponent <ShakeController> (); shake.Shake(); }