ball on a plane physics

Posted By: royr

ball on a plane physics - 08/17/06 18:56

Hi,

I have a ball and plane inside a hollow box. I made the ball a physics entity. The ball drops from it's initial positon on to the plane. The roll and tilt of the plane is controlled by mouse movements.

The physics works except when the ball lands and stops moving while the plane has 0 tilt and 0 roll. In other words the mouse is not moved until the ball goes to a complete stop. Afterwards, the ball refuses to react with the roll and tilt of the plane. Do you have any suggestions how to make the ball roll around the plane when it is completely stopped?

Code:
  
action ball_control()
{

phent_settype(my,PH_RIGID,PH_SPHERE);
phent_setmass(my,10.0,PH_SPHERE);
phent_setfriction(my,10.0);

while (1)
{
//more code here
wait(1);
}
}

action plane_control()
{
while(1)
{
my.roll += mouse_force.x;
my.tilt += mouse_force.y;
wait(1);
}
}



Posted By: demiGod

Re: ball on a plane physics - 08/17/06 19:53

You have to apply a gravity to the ball ex: phent_setgravity(0,0,-500);
And maybe increase the friction value.
Posted By: royr

Re: ball on a plane physics - 08/17/06 20:27

Do you mean set the world gravity?

Code:
 
ph_setgravity(vector(0,0,-386));



I set the gravity in the main function. I also tested it in the ball's action function. Both exhibit the same problem I described above.
Posted By: demiGod

Re: ball on a plane physics - 08/17/06 20:44

If you decrease the ballīs mass say to 1.0 and increase the friction factor the ball works, however, thereīs a ball example in the 3dgs manual under Programming: Events and Physics. Use that code for your base of work.
Posted By: fogman

Re: ball on a plane physics - 08/19/06 19:11

Donīt use pan/tilt/roll, try it with c_rotate.
This should work:

Code:

action plane_control
{
my.polygon = on;
while(1)
{
temp.x = 0;
temp.y = mouse_force.y * time * 3;
temp.z = mouse_force.x * time * 3;
c_rotate (my, temp, IGNORE_YOU);
my.tilt = clamp(my.tilt, -15, 15);
my.roll = clamp(my.roll, -15, 15);
wait(1);
}
}



Do you use a model or a mapentity as platform? Models are working better.
Posted By: FoxHound

Re: ball on a plane physics - 08/20/06 08:45

best to make the plane a physics entity as well and move it by applying torque.
Posted By: royr

Re: ball on a plane physics - 08/21/06 22:15

Thanks. That works perfectly.
Posted By: ello

Re: ball on a plane physics - 08/28/06 08:03

Quote:

Thanks. That works perfectly.




really? inspired by that idea i did a test and found that the plane sometimes couldnt move when a ball was in contact. say, for example i kept the plane nonrotated and some balls where stacked upon it. trying to rotate it afterwards wasnt possible. what is the solution for this?
Posted By: fogman

Re: ball on a plane physics - 08/28/06 15:15

Quote:

c_rotate (my, temp, IGNORE_YOU);




For me, it was the "ignore_you".
Posted By: ello

Re: ball on a plane physics - 08/30/06 06:28

yep
© 2023 lite-C Forums