/// <summary> /// Triggered when the shark collides with the player /// </summary> /// <param name="collidingObject">the object that collides with our shark.</param> protected virtual void OnTriggerEnter2D(Collider2D collidingObject) { // we verify that the colliding object is a PlayableCharacter with the Player tag. If not, we do nothing. PlayableCharacter player = collidingObject.GetComponent <PlayableCharacter>(); if (player == null) { return; } if (collidingObject.tag != "Player") { return; } // we shake the camera - uncomment these two lines if you want to add a shake effect when the shark collides with your player. I thought it was a bit too much. //Vector3 ShakeParameters = new Vector3(1.5f, 0.5f, 1f); //_camera.Shake(ShakeParameters); // we instantiate an explosion at the point of impact. GameObject explosion = (GameObject)Instantiate(Explosion); explosion.transform.position = new Vector3(transform.GetComponent <Renderer>().bounds.min.x, transform.GetComponent <Renderer>().bounds.center.y, 0); MMAnimator.UpdateAnimatorBoolIfExists(explosion.GetComponent <Animator>(), "Explode", true); // we turn the object inactive so it can be instantiated again gameObject.SetActive(false); }
/// <summary> /// Updates all mecanim animators. /// </summary> protected override void UpdateAllMecanimAnimators() { MMAnimator.UpdateAnimatorBoolIfExists(_animator, "Grounded", _grounded); MMAnimator.UpdateAnimatorBoolIfExists(_animator, "Jumping", _jumping); MMAnimator.UpdateAnimatorFloatIfExists(_animator, "VerticalSpeed", _rigidbodyInterface.Velocity.y); }