title: Gravity during player jumping on trampoline
body: <p>So I managed to fix up my trampoline code so that the player will bounce up as if they're on a trampoline. However there are 2 problems I'm having with this code.</p>
  
  <p>Firstly when bouncing on the trampoline it basically launches the player right into the stratosphere and they just keep going never stopping as if there is no gravity to bring them down. Even though I have gravity checked in the player rigidbody settings.</p>
  
  <p>And secondly even if the player is in no where near the trampoline e.g. on a platform that has not got the trampoline script code attached to it will cause the player to be flung up into the air on immediate starting of the game.</p>
  
  <p>The code is as follows below:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class small_trampoline_bounce : MonoBehaviour
  {
  
  bool willBounce = false;
  float bounceHeight = 10;
  public Transform Player;
  
  
  // Use this for initialization
  void Start()
  {
  }
  
  // Update is called once per frame
  void Update()
  {
      Vector3 velocity = Player.rigidbody.velocity;
  
      if (willBounce)
      {
  
          Player.rigidbody.velocity = new Vector3(velocity.x, 0, velocity.z);
  
          Player.rigidbody.AddForce(0, bounceHeight, 0, ForceMode.Impulse);
  
  
          willBounce = false;
      }
  }
  
  void OnCollisionEnter(Collision Trampoline)
  {
  
      if (Trampoline.gameObject.name == "Player")
      {
          willBounce = true;
      }
  
  }
  
  }
  </code></pre>
  
  <p>Also this is the current status of settings for both the trampoline and the player</p>
  
  <p>Player settings:
  <a href="http://gyazo.com/b4d924849a86e5158361f6081948e39f.png" rel="nofollow">http://gyazo.com/b4d924849a86e5158361f6081948e39f.png</a></p>
  
  <p>Trampoline settings:
  <a href="http://gyazo.com/ded2884b93dd53c9e1b7fabc57e4fe51.png" rel="nofollow">http://gyazo.com/ded2884b93dd53c9e1b7fabc57e4fe51.png</a></p>