The Daily Click ::. Forums ::. Klik Coding Help ::. Gear shifting on racing games?
 

Post Reply  Post Oekaki 
 

Posted By Message

Mr G



Registered
  31/12/2008
Points
  178

VIP MemberPS3 OwnerI like Aliens!Attention GetterDos Rules!
14th April, 2009 at 14:11:08 -

I'm trying to find a way to make a realistic gear shifting and a gauge for a racing game idea that I might develop. I've tried it doing counters but it doesn't act that realistic enough.

What do you guys think would be the best way to make realistic gear shifting, gauging and maybe a realistic racing engine?

 
Image

http://create-games.com/project.asp?id=1549

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
14th April, 2009 at 14:32:00 -

I don't know what racing engine you're using, but just be sure to change acceleration values according to current speed and gear, Counters should follow suit... You could go pretty complicated and control things manually. For instance, set the speed to the RPM times a certain value for each gear. Once the RPM's get high, switch to another gear that adds speed according to the specific value for that gear (probably going to be a trial and error process to find the right value)

 

  		
  		

Mr G



Registered
  31/12/2008
Points
  178

VIP MemberPS3 OwnerI like Aliens!Attention GetterDos Rules!
14th April, 2009 at 19:10:09 -

I'm not using any engine at the moment, I just wanna make one from scratch.

I'm thinking of making a gear counter, rpm counter and a speed counter. The speed counter will probably have a limit of 200 (for kmph), the gear counter will be maxx 5 or 6 and the RPM will probably maxx 800 or so. Does a counter support up to 9999 btw?


So for I'll add A,B,C,D,E values for the gear shifting. When the counter is 0-10 it will be gear 1, for 11-40 it will be gear 2, for 41-85 it will be gear 3, for 86-115 it will be gear 4 and 115-200 will be gear 5.

When the gear is on 1 whenever I repeatedly press accelerate it will add 1 to counter every 50 milliseconds, on gear 2 every 80 milliseconds, on gear 3 every 1 second, on gear 4 every 1,2 seconds, on gear 5 every 1,5 seconds (I guess it should work )

Also it will also subtract from the speed counter every 75 milliseconds

I don't really know if it will work well but if anyone can give me advice on how to work on a better one I'll try it out too

Edited by Mr G

 
Image

http://create-games.com/project.asp?id=1549

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
15th April, 2009 at 06:49:28 -

Acceleration=-(Difficulty*(CurrentSpeed-GoodSpeed)^2) + MaxAcceleration

Acceleration is.. like power, whatever you want to put it. It's how much faster the car goes.
CurrentSpeed is the speed your car is going at.
GoodSpeed is the best speed at which you want to be driving at that gear.
MaxAcceleration is the maximum acceleration that car can reach.
Difficulty is the hardest to explain. Not exactly difficulty; it's more like how closely you have to follow the GoodSpeed. It should be above 0. Don't set it too high, though, otherwise your your car won't be able to reach a high enough speed to change gear.

Let's say you expect the player to use gears at 0,10, 20, 30, 40. Maximum Acceleration would be.. say, 10. This would be an easy car to drive, so let's set difficulty at 0.05
Gear 1: Acc = -(0.05*(CS-0)^2) + 10
Gear 2: Acc = -(0.05*(CS-10)^2) + 10
Gear 3: Acc = -(0.05*(CS-20)^2) + 10
Gear 4: Acc = -(0.05*(CS-30)^2) + 10
Gear 5: Acc = -(0.05*(CS-40)^2) + 10

This means that if you're driving at 0 (starting the car) at gear 0, acceleration will be 10.
At speed 10, acceleration will be
5 at gear 1
10 at gear 2
5 at gear 3

If you're driving at 30, then you suddenly drop from gear 4 to gear 2, then your acceleration becomes -10, which would cause your car to jerk around until it slows down to 24.1, much like shifting gears in a real car.

Just fiddle around with the Acceleration and Difficulty until you get what you like. Difficulty 0 means that the car doesn't use gears at all.

It's a very simplified system... but the more realistic you want it, the harder it gets

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Mr G



Registered
  31/12/2008
Points
  178

VIP MemberPS3 OwnerI like Aliens!Attention GetterDos Rules!
15th April, 2009 at 10:02:58 -

I think I understand what you said Muz but I have no idea how I can incorparate it in MMF2

But I'll mess with what you said



The reason I what to learn this is to make a drag race game btw

 
Image

http://create-games.com/project.asp?id=1549

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
15th April, 2009 at 10:13:45 -

Take that:
Acceleration=-(Difficulty*(CurrentSpeed-GoodSpeed)^2) + MaxAcceleration

For object Car:
Alterable Value A = Difficulty
Alterable Value B = Max Acc
Alterable Value C = Good Speed at Gear 1
AV D-G = GoodSpeed at Gear 2-5
AV H = Acceleration
AV I = Speed

If Gear = 1,
Set Car("Acceleration") = -(Car("Difficulty")*(Car("Speed")-Car("GoodGear1"))^2) + Car("Max Acc")

If Gear = 2,
Set Car("Acceleration") = -(Car("Difficulty")*(Car("Speed")-Car("GoodGear2"))^2) + Car("Max Acc")


..and so on

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Mr G



Registered
  31/12/2008
Points
  178

VIP MemberPS3 OwnerI like Aliens!Attention GetterDos Rules!
15th April, 2009 at 12:37:18 -

Thanks for the explanation

 
Image

http://create-games.com/project.asp?id=1549
   

Post Reply



 



Advertisement

Worth A Click