Rigidbody questions

So i have this ball that i use in a puzzle game. You have to move the ball around a level. The ball is a simple sphere and has a rigidBdy attached to it.

I see some strange behaviour that doesn’t look real pysics…
For example i have a ramp that is tilted 30 degrees downwards. I expect that my ball should accelerate because it is going down, right? Well, when i add force to my ball, i see him accelerate but when i stop adding that force, the ball is slowing down. This is not good because it isn’t real.

controller.AddForce(Vector3.right*Time.deltaTime);

I expect that my ball should accelerate but i notice that the ball gets a speed instead of slowly accelerate, is this possible?
Should i keep a variable with the currentSpeed and add value to it every frame so i simulate the acceleration?

Also, are their settings so that when the ball goes downhill, he realy accelerate because i have the impression that the speed at the top of the cube is the same then at the bottom.

I have tried changing mass, drag but i can’t seem to find a setting that does what i want.

You need to give it a custom Physic material that takes minimum friction and has much lower friction than default. Physic materials handle all bouncy/sticky issues for collisions.

The max angular velocity in the physics settings will prevent a ball from accelerating past a certain speed, so increase that if you want it to go faster.

–Eric

How can i add a custom material? Currently i am using bouncy but it isn’t good…

I will check the angularVelocity.

Gravity is cheating on me…
Just did a test. When i start with my ball a few units high, he bounces 3 times. When i start my ball at 50 units high, he also bounces 3 times and when i look at the Y values, it doesn’t realy accelerate.
Even when i start the ball at 200 high it seems like his falling is always the same value…

Shouldn’t he be accelerating according to laws of gravity? Am i missing something here…

not sure if this will help but here are some general physics tips:

Make sure your scale in the game is correct. The physics engine doesn’t like really small or really big scenes.

Use the fixedUpdate function to add forces.

New physicsmaterials can be created by selecting a standard one and selecting duplicate from the menu.

good luck!

Can you post the code you are using to control the ball? You might be adding forces that are unexpectedly slowing the ball down.

unction axisChange()
{
	var controller : Rigidbody = GetComponent(Rigidbody);
	var changeH : float = Input.GetAxis("Horizontal");
	var changeV : float = Input.GetAxis("Vertical");
	
	//Movement
	if(changeV > 0)
	{
		movement = Vector3.right*currentSpeed;
		controller.AddForce(Vector3.right*currentSpeed*Time.deltaTime);		
		//controller.velocity.x = 50*Time.deltaTime;
	}
	if (changeV < 0)
	{
		movement = Vector3.right*currentSpeed;
		controller.AddForce(-movement*Time.deltaTime);
	}
	
	if(changeH > 0)
	{
		movement = Vector3.forward*currentSpeed;
		controller.AddForce(-movement*Time.deltaTime);
	}
	if(changeH < 0)
	{
		movement = Vector3.forward*currentSpeed/2;
		controller.AddForce(movement*Time.deltaTime);
	}
}

function keyPressed()
{
	var controller : Rigidbody = GetComponent(Rigidbody);

	if(Input.GetButtonDown("Jump"))
	{
		movement = Vector3.up*jumpStrength;
		controller.AddForce(movement);
	}
}

This is the code.

I test by just jumping, not going in one direction or another. Just pres the space bar a few times so the ball flies high and then i let him fall down.

It’s possible the mass, size, and/or drag of the rigidbody are limiting its terminal velocity. The air resistance the object encounters as it falls will work against gravity. Eventually, gravity and air resistance will equalize and the object will fall at a constant velocity. This might be what you’re seeing.

Have you tried giving the rigidbody a drag of zero (i.e. no air resistance)?

A small tip: in your code, you can simply refer to “rigidbody” to get the rigidbody attached to the current game object, instead of calling GetComponent(Rigidbody).

Hope this helps.
Ehren

Ah the drag… this seems to work. When i put it to 0 i see a definitly acceleration when the ball falls. I put this highr because i noticed my ball bounces less when the drag is higher and that’s what i wanted. I now have created a new physics material with a lower bouncyness so the ball bounces less so i can decrease the drag and he accelerates more.

This resolves my issue. Thanks or your input guys :slight_smile: