In my 3d game, I have a sort of bounce pad that when jumped on, sends the player up with a certain force,
the problem is, when it adds the force, i cant come back down, can someone please help me with this??
If it helps, this is the code for the Bounce Pad
using UnityEngine;
using System.Collections;
public class BouncePad : MonoBehaviour {
public float force;
// Use this for initialization
void Start () {
}
void OnTriggerEnter(Collider Player){
Player.GetComponent<Rigidbody> ().AddForce (Vector3.up * force);
Debug.Log ("It WORKS IT WORKS");
}
}
The Player has IsKinematic disabled and Gravity enabled.
There are no compiler errors
Thanks in advance!!
Does the object continue to move up at the same rate, or does it start to slow down at ALL? If slowing down, then gravity IS working, and you probably just need to adjust it’s strength, or reduce the force you apply. If you are not sure, increase gravity as a test. ( docs on changing that… Unity - Manual: Physics)
Hi! The easiest and simple way to this would be to actually add force to the player and basically create your own gravity and this sounds crazy but can be simple so on your player in: void Update (). Add a if statement checking for the player being grounded. I’ll later add a C# code in this answer for you
If you however want to try it on your own basically what you do is: have a variable for your gravity (I prefer using a float variable). In void update use and if statement like this: “if (gameObject.IsGrounded = false” you must then have a vector 3 to add downward force so use: rigidbody.AddForce (0, (-) gravity varible, 0);
That is how its done I think but I’ll test it later for you
Hi! The easiest and simple way to this would be to actually add force to the player and basically create your own gravity and this sounds crazy but can be simple so on your player in: void Update (). Add a if statement checking for the player being grounded. I’ll later add a C# code in this answer for you
If you however want to try it on your own basically what you do is: have a variable for your gravity (I prefer using a float variable). In void update use and if statement like this: “if (gameObject.IsGrounded = false” you must then have a vector 3 to add downward force so use: rigidbody.AddForce (0, (-) gravity varible, 0);
That is how its done I think but I’ll test it later for you