Jump and land quicker (476798)

i have a rigidbody with a box collider as my player. I dont want to use the character controller, but imitate its capabilities. I can make my player jump by several methods. Adding to

rigidbody.velocity.y = 10;

or

rigidbody.AddForce(Vector3.up * jumpSpeed);

but they happen to jump like its on the moon or something. i want quick fast jumps and lands but only for this gameObject. AND my scale is at default (1, 1, 1)

thank you

Increase mass/gravity, reduce drag, or simply use the same method as the character controller… changing your Y position directly.
Tweak your physics settings until you find something suitable…

ive been tweeking and playing with physics for days. im so frustrated. Drag is always 0.05, it cant go lower than 0 anyway.
changing the y position might be an easier solution at the moment but i feel like it will give me troubles in the future

youre going to have to post more code.

youre using the correct functions, so I assume youre not using them correctly.

function Update() 
{
	if( Input.GetKeyDown(KeyCode.Space) )
 	{
 		Jump();
 	}
 	
 	if( Input.GetKey(KeyCode.RightArrow) )
 	{
 		WalkRight();
 	}
 	
 	if( Input.GetKey(KeyCode.LeftArrow) )
 	{
 		WalkLeft();
 	}
}

function FixedUpdate()
{
	if( rigidbody.velocity.y > 0 )
	{
		rigidbody.velocity.y += Physics.gravity.y * Time.deltaTime;
	}
}

function Jump()
{
	rigidbody.velocity.y = 10;
}

function WalkRight()
{
	rigidbody.velocity.x = 5;
}

function WalkLeft()
{
	rigidbody.velocity.x = -5;
}

Are you not using the rigidbodies gravity? Just wondering why you are doing this?
rigidbody.velocity.y += Physics.gravity.y * Time.deltaTime;

otherwise it looks fine, although I would generally use:
rigidbody.AddForce(Vector3.up * jumpSpeed, ForceMode.VelocityChange)

tweak jumpspeed to a value that makes the char jump the required amount. It would start with 1. Its probably going to be a low number

yeh i just changed it now and works how i like it to.

var gravity : float = 40;

function Update() 
{
	if( Input.GetKeyDown(KeyCode.Space) )
 	{
 		Jump();
 	}
 	
 	if( Input.GetKey(KeyCode.RightArrow) )
 	{
 		WalkRight();
 	}
 	
 	if( Input.GetKey(KeyCode.LeftArrow) )
 	{
 		WalkLeft();
 	}
 	
 	ApplyGravity();
}

function ApplyGravity ()
{
    if (rigidbody.velocity.magnitude > 0.1)
    {
        rigidbody.velocity.y -= gravity * Time.deltaTime;
    }
}

function Jump()
{
	rigidbody.velocity.y = 20;
}

function WalkRight()
{
	rigidbody.velocity.x = 5;
}

function WalkLeft()
{
	rigidbody.velocity.x = -5;
}

ill try the add force and see the difference. is that the proper way to do it or something? coz i dont wana have problems in the future with my method

There are some things to keep in mind with physics which are in the documentation…

All functions/changes should be done in FixedUpdate… I see youre calling that Apply Gravity Function from Update.

Have a quick look at the example: Unity - Scripting API: Rigidbody.velocity

Two other things…

  1. What if the user keeps smashing the jump key… the player will keep boosting upwards. You should make it so the jump will only activate if the player is on the ground (unless you are trying to achieve a multi jump thing)

  2. Not sure if your gravity apply test is correct. It looks like it will stop applying gravity once the player stops moving upwards. You want it to end up in negative (down) velocity so the player falls.