Hi everybody.
I’m currently making a rigidbody character controller and it’s nearly complete, but rather than just adding a specific speed to make my character to jump I’d like to use a force.
I have the force calculations worked out perfectly, only it seems to be running into a bug when my character is touching 2 objects.
When the character is touching 2 objects/standing on 2 cubes it jumps at about half the height as it usually would, most of the time. Sometimes on rare occasions it still jumps the height that it should. when it’s standing on/touching one object it jumps as it should all of the time. and every once in a while when you hold the jump button down it’ll just start bouncing at about a quarter of the height it should be jumping…
When setting the speed of the rigid body by using
rigidbody.AddForce(Vector3(0, jumpSpeed, 0), ForceMode.VelocityChange);
it works perfectly… except for the bouncing part.
Also the bouncing happens faster than my jump delay should permit, also it appears to start when touching 2 objects and not one (such as a wall and the ground) and then you can continue on bouncing as long as you hold down your jump button.
for my jump part of my scrip I’m using this
// Jump
if (grounded Time.time > (lastJump + jumpDelay)) {
if (Input.GetButton(“Jump”))
{
BroadcastMessage(“CalculateJumpVerticalSpeed”);
forceAdded.y = (gravity * rigidbody.mass) + jumpForce;
lastJump = Time.time;
}
}
When using forces to make the jump I’ve checked the force added right before the rigidbody.addForce was made and it’s always the same amount that it should be to reach the distance I want.
So this makes me think it’s not a problem with my scripting. Possibly the physics settings? or maybe unity.
For the physics materials I’ve set everything to a material with 0s for everything, friction, bounciness, ect. the friction and bounce combines were set to minimum.
I’ve also gone to edit/project settings/physics and played with those settings and it made no difference.
any ideas on this problem?