- Home /
Why does the player jump is not so high if he touch 2 objects at the same time as if it touch only 1 object?
void OnCollisionStay(Collision collisionInfo)
{
if (collisionInfo.gameObject.tag == "jumpable_thing")
{
CanJump = true;
}
}
void OnCollisionExit(Collision collisionInfo)
{
CanJump = false;
jump = false;
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed);
if (jump == true)
{
rigidbody.AddForce(Vector3.up * jumpSpeed);
CanJump = false;
jump = false;
}
}
Where does he touch them? Ground? Side? Try to turn down friction, maybe. You should possibly be more descriptive with your problem, it's really hard to figure out what you are up to / have already done when your question is just consisting of a title and a small code snippet..
by saying "object" I mean the ground. This is basically the jumping script (so complex, because I don't want a Player to be able to jump every time). So, when the Player is colliding with two objects with "jumpable_thing" tag it jumps not so high as if it touch only 1 "ground" object.
dude, mm.. why do you have two variables CanJump and Jump? aren't they doing the same thing?
Answer by kumarc123 · Dec 08, 2014 at 06:48 PM
Avoid OnCollisionStay and OnTriggerStay. OnCollisionEnter / OnTriggerEnter is sufficient for this task.
Your answer
Follow this Question
Related Questions
Animation OnTriggerEnter 1 Answer
How do I make a scene change when my Player collides with a item? 1 Answer
Combine common surfaces 1 Answer
Weirdest Collision EVER 1 Answer
Particle collider not working 0 Answers