Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So, I'm making a ball game. Where you pick up the ball, drop it on a ramp, and it flies off in to blocks. The only problem right now is it falls at a normal speed, then lightly falls off, not nearly fast enough to get over the wall and hit the blocks.

Is there any way to make the ball go faster down the ramp? Maybe even make it go faster depending on what height you dropped it from (e.g. if you hold it way above the ramp, and drop it, it will drop faster than if you dropped it right above the ramp.)

share|improve this question
    
Do you need strict control over the ball's path? If not, I'd suggest slapping on a rigidbody and letting PhysX do the work. –  ktodisco Apr 2 '12 at 16:22
    
this can be done with base line physics integration V_f=V_i + a*t considering a is gravity in this scenario, so you can either write up your own physics, or see if Unity has its own physics framework for you to use. –  gardian06 Apr 2 '12 at 16:43
    
Remember that physics engines expect you to run your simulations at scale so since Unity works in Meters. 1. What size is your ball? If it's really big, the ball will roll like a bolder and not like a pebble. 2. What is the mass on the ball? 3. Is it running with default gravity? 4. What type of PhysicsMaterial are you using? Provide these answers and I can give you some better ideas. –  Rubber Mallet Apr 2 '12 at 16:48
2  
@gardian06 Unity does have it's own physics framework... it integrates PhysX, as I had already mentioned... Also, explicit euler is not the ideal form of integration to use for a physics simulation. –  ktodisco Apr 2 '12 at 16:54
    
ktodisco I already have a rigidbody on it, the physics of that aren't strong enough. Guardian I'm already using Unity's engine –  Timothy Williams Apr 2 '12 at 18:17
show 2 more comments

3 Answers

up vote 0 down vote accepted

One possibilty would be to use AddForce in the direction of the current velocity of the rigidbody. You could measure the height of the dropping point and use this number to calculate the added force.
Pseudocode:

var r:Rigidbody = ball.rigidbody;
var power:float = 3.0;
r.AddForce(r.velocity.normalized * power);

See AddForce, and Force.Mode.

share|improve this answer
add comment

It sounds like you want to increase the mass of the ball. Play around with the parameters of the Rigidbody-component in Unity. Increase the mass, set "drag" to zero etc. Maybe you'll also have to tweak your level a bit for it to work (if your ramp is really steep, then there's probably no way the ball will jump over that.. or you could cheat and apply a force whenever the ball hits the bottom of the ramp).

share|improve this answer
    
Drag is already set to zero, and mass is 1. But I'll mess around with those. The ramp makes a "J" shape, the ball falls down the arch of the J then is supposed to shoot off the bottom. I'll mess around with the stats and let you know how it goes. –  Timothy Williams Apr 3 '12 at 0:02
    
Changing the mass seems to do nothing at all, I can set it to 50 or 0.0001 and there's no difference. –  Timothy Williams Apr 3 '12 at 1:26
    
@TimothyWilliams did you try increasing the gravity as well? It's in Edit > Project Settings > Physics. Depending on the scale of your world, you might have to increase gravity to make it look more realistic. –  bummzack Apr 3 '12 at 6:05
    
Changing the gravity doesn't help much either, decreasing it makes it flow high enough over the wall, but then it goes too slowly. –  Timothy Williams Apr 3 '12 at 19:58
add comment

Increase velocity of the ball in y direction and increase restitution of the wall and ball

share|improve this answer
    
How do I do those things? And what would each thing do? –  Timothy Williams Apr 5 '12 at 22:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.