- Home /
Player gets stuck after AddForce in Air
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!!
Oops, no it doesn't, it took me down a little after a jump, but thats it.
Answer by Glurth · May 05, 2016 at 03:32 PM
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... http://docs.unity3d.com/Manual/class-PhysicsManager.html)
Answer by V-O-D-Games · May 09, 2016 at 09:54 AM
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
Answer by V-O-D-Games · May 09, 2016 at 05:19 PM
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
Lol sorry bad internet connection made me make 2 answers
What do you mean by "gravity Variable"?? Other than that, i'll definitely try it, no need to bother yourself to test anything, just go help other people :)
Your answer
Follow this Question
Related Questions
Unity random generator kills programm 2 Answers
Most efficient way to get scores 1 Answer
Skybox Only Rendering One Side? 2 Answers