- Home /
Double gravity when standing on two colliders, bug?
Hey,
We are developing a game as part of our semester project. In the game you play as a ball that has to reach the goal. The world itself is contructed from a lot of 1x1 cube prefabs.
The character has a jump ability (done by addforce in y-axis). Our problem is that when the character is in the middle of two adjacent cubes, it will only jump half as high.
Our preliminary guess was that the game somehow applied double gravity(one for each collider). We tested this by making two cubes in the exact same spot, and as assumed, the character jumped half of the intended height.
Just wondering if this is a known bug or if we are doing something wrong? There is a video showcasing our problem: http://www.youtube.com/watch?v=51G2ZozdFZ4
Regards
EDIT: We tried reducing the game to the very basic components and this is the ONLY script running:
using UnityEngine;
using System.Collections;
public class VeryBasicMovement : MonoBehaviour {
Vector3 brake;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void FixedUpdate () {
if(Input.GetKey(KeyCode.LeftArrow)) {
rigidbody.AddForce(new Vector3(-50, 0, 0));
}
if(Input.GetKey(KeyCode.RightArrow)) {
rigidbody.AddForce(new Vector3(50, 0, 0));
}
if(Input.GetKey(KeyCode.UpArrow)) {
rigidbody.AddForce(new Vector3(0, 0, 50));
}
if(Input.GetKey(KeyCode.DownArrow)) {
rigidbody.AddForce(new Vector3(0, 0, -50));
}
if(Input.GetKeyDown(KeyCode.Space)) {
rigidbody.AddForce(new Vector3(0, 400, 0));
}
ApplyBrakes();
}
void ApplyBrakes() {
brake = -1 * rigidbody.velocity * 400 * Time.deltaTime;
rigidbody.AddForce(new Vector3(brake.x, 0, brake.z));
}
}
And it still has the same problem.
Is there a negative force in the y-axis added to the ball that is being called by the boxes themselves? Since you're using an AddForce to the ball's rigidbody to create the jump I'm not sure why gravity would act differently unless your boxes have colliders which contain a trigger to reduce the gravity or are applying a negative y-axis force.
No there is not. Just tried it with normal cubes. I guess that means that the problem scope is somewhat reduced to the character now.
Answer by sparkzbarca · Nov 15, 2012 at 06:42 AM
yea gravity doesnt work like that. :P Its really just a force applied constantly in the -vector3.up direction.
You could test this by seeing what the velocity is with gravity disabled.
there is a gravity checkmark in the rigidbody. If you turn it off and your velocity is still halved your code is being wonky not gravity. (i understand you'll keep going up but you should do so half as fast)
Your answer
![](https://koobas.hobune.stream/wayback/20220613083856im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Applying Normal force from ground to player 1 Answer
Gravity on a rotating platform 1 Answer
how to make an object fall slowly ? 2 Answers
How can i rotate player when player jump ? 2 Answers
Roof of the builiding (physics) 1 Answer