Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (TipmyPip, izorro), 556 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ball on a plane physics #86563
08/17/06 18:56
08/17/06 18:56
Joined: May 2006
Posts: 19
R
royr Offline OP
Newbie
royr  Offline OP
Newbie
R

Joined: May 2006
Posts: 19
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);
}
}




Re: ball on a plane physics [Re: royr] #86564
08/17/06 19:53
08/17/06 19:53
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
You have to apply a gravity to the ball ex: phent_setgravity(0,0,-500);
And maybe increase the friction value.

Re: ball on a plane physics [Re: demiGod] #86565
08/17/06 20:27
08/17/06 20:27
Joined: May 2006
Posts: 19
R
royr Offline OP
Newbie
royr  Offline OP
Newbie
R

Joined: May 2006
Posts: 19
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.

Re: ball on a plane physics [Re: royr] #86566
08/17/06 20:44
08/17/06 20:44
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
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.

Re: ball on a plane physics [Re: royr] #86567
08/19/06 19:11
08/19/06 19:11
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
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.


no science involved
Re: ball on a plane physics [Re: fogman] #86568
08/20/06 08:45
08/20/06 08:45
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
best to make the plane a physics entity as well and move it by applying torque.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: ball on a plane physics [Re: fogman] #86569
08/21/06 22:15
08/21/06 22:15
Joined: May 2006
Posts: 19
R
royr Offline OP
Newbie
royr  Offline OP
Newbie
R

Joined: May 2006
Posts: 19
Thanks. That works perfectly.

Re: ball on a plane physics [Re: royr] #86570
08/28/06 08:03
08/28/06 08:03
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
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?

Re: ball on a plane physics [Re: ello] #86571
08/28/06 15:15
08/28/06 15:15
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Quote:

c_rotate (my, temp, IGNORE_YOU);




For me, it was the "ignore_you".


no science involved
Re: ball on a plane physics [Re: fogman] #86572
08/30/06 06:28
08/30/06 06:28
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
yep


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1