Trying to simulate the flight of a golf ball

Talk about making games.

Trying to simulate the flight of a golf ball

Postby TommyComputer » Tue Dec 14, 2010 12:54 pm

Hello,
I'm new to Game Editor and trying to make my first game, based on golf. I can set a golf club with speed and angle to get a ball hit up into the air by the player, but the bounce using collision doesn't look natural and it doesn't stop. Any tips would be appreciated.
TommyComputer
 
Posts: 2
Joined: Tue Dec 14, 2010 12:46 pm
Score: 0 Give a positive score

Re: Trying to simulate the flight of a golf ball

Postby skydereign » Tue Dec 14, 2010 10:27 pm

To make it look really accurate, you will have to calculate the velocity of the ball, given angle and speed. Then on collision set the velocities of the ball. Generally you can use angle and directional_velocity, but depending on your calculations, or lack thereof, there will be varying levels of accuracy.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Trying to simulate the flight of a golf ball

Postby DST » Tue Dec 14, 2010 10:28 pm

Ball>draw Actor>
Code: Select all
directional_velocity *=.98;   //make ball slow down
if(directional_velocity<.01){  //make ball stop if nearly stopped (prevents shaking)
directional_velocity=0;
}


You can also then create a float (real) array, and set the slowdown for terrain types;
for instance
Code: Select all
tslowdown[0]=.998;  //speed to slow down while in air
tslowdown[1]=.99;    //speed to slow down while on grass
tslowdown[2]=.90;    //speed to slow down while on sand


then have the ball start with a terrain of 0; and change that to 1 on collision with ground, or 2 on collision with sand trap.

then
Code: Select all
directional_velocity*=tslowdown[terrain];


You could just nix the slowdown in the air, that may be best if it doesn't slow down till it hits something.

Then on your collision, try adjusting the power of the ball. There are 4 variables in physical response;
The 3rd one is 'final velocity multiplier' for event actor. You can adjust this till you get a response you like.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Trying to simulate the flight of a golf ball

Postby TommyComputer » Wed Dec 15, 2010 5:11 pm

Thanks - I will try that straight away
TommyComputer
 
Posts: 2
Joined: Tue Dec 14, 2010 12:46 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest