PLEASE HELP FAST! Need help with A6 physics

Posted By: Dragon

PLEASE HELP FAST! Need help with A6 physics - 12/10/04 02:56

Can someine tell me how I can make a ball wich I can change the direction with the arrow buttons, but it's not supposed to roll back up a hill unless it has enough speed.
Thanks
Posted By: b_102373

Re: Ball steering Physics - 12/10/04 15:26

Try the Newton Physics engine. Download the free 30mb download with the example games and documentation and there is a small demo exactly what you want. I think its called "Water".

Newton Physics Engine
Posted By: Dragon

Re: Ball steering Physics - 12/10/04 20:24

I would like to do it with 3dgs
But thanks anyway
Posted By: Doug

Re: Ball steering Physics - 12/11/04 05:03

Unless somebody is working on the exact same project and wants to give you all his code (unlikely ) we are going to need more details from you.

Tell us what you've done so far, what isn't working, etc. Right now we got nothing to go on.
Posted By: Marco_Grubert

Re: Ball steering Physics - 12/11/04 05:13

What you'll want to do is call phent_settype and the other setup functions (phent_setmass, damping, etc)- see AUM for examples. Then you'll need a while loop where the keys are checked and phent_addforceglobal is called to push the sphere around. You might find some code snippets by searching in this forum.
Posted By: Dragon

Re: Ball steering Physics - 12/11/04 05:16

ok, thanks
What I need is a simple physics code with wich I can simply control the pan of a Physics entity and I don't want a ball to roll back up a hill, or go forward without force from a downhill roll.
Posted By: fastlane69

Re: Ball steering Physics - 12/11/04 05:21

To control the pan, you will need to add an angular force. To do this, you use phent_addcentralforce with a veclocal off center. This will apply an off center force and effectively rotate (ie change the pan) of your ball.

Regarding your requirements that the ball not roll unless it's on a hill (Guessing something like Marble Madness perhaps? ), then as long as gravity is set within the Physics Engine, this is exactly what will happen.
Posted By: Dragon

Re: Ball steering Physics - 12/11/04 06:15

Yes, It was called Marble maddnes
This is my code I'm using:

Code:
 
action ball
{
p_player=my;
my.shadow=on;
phent_settype(my,PH_RIGID,PH_SPHERE);
phent_setmass(my,5,PH_SPHERE);
phent_setfriction(my,40);
phent_setelasticity(my,40,10);
phent_setdamping(my,20,20);
var dir[3];
while(1)
{
vec_set(dir,nullvector);
if(key_a)
{
dir.x-=1;
}
if(key_d)
{
dir.x+=1;
}
if(key_w)
{
dir.y+=1;
}
if(key_s)
{
dir.y-=1;
}
vec_rotate(dir,vector(camera.pan,0,0));
vec_normalize(dir,80*time);
phent_addtorqueglobal(my,dir);
wait(1);
}
}

function initialize_physics
{
ph_setgravity(vector(0,0,-380));
ph_setcorrections(20000,0.1); //60000 0.01
}



function main()

{
initialize_physics();
load_level("lvl1.wmb");
}



But with that the ball rolls back up the hill. Where do I change that?
Posted By: Marco_Grubert

Re: Ball steering Physics - 12/11/04 06:36

Try decreasing torque or increasing gravity.
Posted By: Dragon

Re: Ball steering Physics - 12/11/04 20:17

No, that doesn't work
I tryed both.
Posted By: Dragon

Re: Ball steering Physics - 12/13/04 15:40

can no one help me?:(
Posted By: EX Citer

Re: Ball steering Physics - 12/14/04 00:45

Would the physics (no real physics) of MandrinPinball work for you? HM... BAd idea.... Real physics are better if you can use them.

EX Citer
Posted By: Marco_Grubert

Re: Ball steering Physics - 12/14/04 10:19

Can you mail me your level & code ? mgrubert@conitec.net
Posted By: Marco_Grubert

Re: Ball steering Physics - 12/15/04 07:41

It's really just a matter of playing around with the numbers until the ball acts the way you want it to. Reducing friction and torque are a good start but if your level planes have different slopes then obviously the setting that just about keeps the ball from rolling up the steep slope will allow the ball to easily climb a shallow one.

A couple of ideas:
Compare current and previous z position. If z has increased then apply a force from current to old position or even better add a counter-torque that slows down the ball so that it can't move on in this direction. Also check the current rotational speed and stop adding torque if it's above a certain threshold.
Posted By: BERG

Re: Ball steering Physics - 12/15/04 08:08

have you taken a physics class? if you did, think about how a force is broken up into components, and set the up component to the up key, the down component to the down key, and so on. and set this into a while loop.
if you don't know how to break it up into comonents i will help you out. but i will not spill my ball code just like that tho! it took me a while to figure it out!

Alex
Posted By: Dragon

Re: Ball steering Physics - 12/16/04 02:03

Thanks for all the help.
I think I can solve the problem now. And otherwise I'll ask again.
© 2024 lite-C Forums