• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Rapha

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

158 Neutral

About Rapha

  • Rank
    Member
  1. Hi to all beloved co-posters ! Bmarci, thanks a lot for saying what i was going to say ^^ More precisely, i would say, yes, this is going to fail, as almost any other car topic on the forum. Of course there are a lot of errors in my (very) simple explanation. The whole purpose was to get people to say "hey this is not the way you should do that !", or even more valuable "hey there is a faster/easier way to do that !". So if i had all knowledge already, i would finish my game and make a real tutorial instead of a "general car ways of doing things" topic [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] My goal is ultimately to explain everything we learned on the first topic, and maybe if i estime myself enough give some advices (like do not believe marcos tutorial will give you a nice car ^^). I have a LOT of litterature on the subject i will post, etc. But right now, i feel like trying to make a "reference" first post is kind of a waste of time as there is too much things to discuss, and making it look "good" won't make it good for real. The idea is to get people to understand this is an open debate and ideas/tips sharing topics, which i hope will let us gather enough intel to be able to provide a few good advices on the first post. As i see it, all kinds of handy formulas, links, tips, and even different "ways" of doing things will be explained in the first post. Bu right now, this thread is highly unrecommandable, especially for newcomers, there are better places to start, like marcos monster, phors or the tutorial on gamedev, which are all good reads. And, finally yes, i think all noobies car devs are going the same way those times, and maybe a fresher starting point would be necessary. [quote]Beside the fact that marco monster is 10 years old, it cover everything so well, its just the best way to start in my opinion.[/quote] Oh yeah, +1k to that. And maybe even before that getting familiar with driver knowledge before going into physics. The value of the first post when completed would not be to do what marcos did, but instead, starting where it stopped. So let's say you have implemented everything he said, and even a few more things, but you are very disappointed because your car is not feeling right. I already learned very valuable things (like role of differentials and so), that i think are worth explaining in the first post, in time, when i'll have implemented and understood them myself. And finally having a few videos demos, data sets and reference values would be a great contributions for people coming from marcos tutorial or trying to implement it. [quote]Of course, its always interesting to see some reading on car physics, a subject that passionate all of us, but the fact of melting all kind of question and answer together make it really confusing and not that enjoyable to read IMO.[/quote] The fact is, we (i) have so many questions, i feel like creating topics for all of them would result in terrible forum flooding. So the idea is to ask things as they are coming, and when i figure out enough of them i'll summarize the first post well [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] And then it would be a great time for constructive feedback, as we are thinking towards future readers and explaining things correctly. --- That being said, let's go back to main topic : car [s]science[/s] alchemy ! --- EDIT : Wow i just realized there are very interesting things being said in the previous car topics ! Maybe some of my questions have been answered there. If that is don't bother linking the other topics, i'm reading them right now [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] A few words on the differential topic i started : i was just talking of a flat multiplier in my sim actually : engineTorque * gearRatio * diff * throttleInput. Very dumb thing, compared to how advanced a real differential is. I personnaly do not use an axle, instead i add torque to the drive wheels directly, and so, they get individually slowed/accelerated in a corner. If cornering without throttle, the inner wheels is going slower than outer wheel (normal), but if cornering with throttle, that's the opposite. Actually wihtout differential, the inner wheel has to slide on itself, which works but is far from good. And must have an influence on cornering. Anyway i just deactivated slip ratios, engine torque and all things related to concentrate on drifting and cornering behaviour. No traction circle either for now. So i'm not on power drifting, but more on braking->more weight to front->oversteer drifts. I think i'll code real suspesions/springs and enhance my mastery of steering_input_control / general lateral forces manipulations before i get more into combined lateral and longitudinal grips. Step by step ! --- [quote name='kunos' timestamp='1348808530' post='4984607']the easiest and more common way of getting load is to treat the tyre as a spring and get the load from that spring compression... no calculation needed.[/quote] [quote name="edy"]That's right, you don't need to calculate this. In my case (Unity 3D) I have rigid body physics that just work. So my vehicle is constructed simply as a rigid body with 4 contact points and a simple suspension on each one (spring + damper). If I put this "vehicle" over a terrain it will behave as if it is sliding on ice (no friction) but suspension, weight transfer and weight load at each contact point will just work.[/quote] No calculations... does not work for me, sorry ^^ You mean the physical engine does it for you ? You mean, the spring/wheel will compress because of car accel, and the final force on each tyre will be way more reasonnable than in a vehicle without suspension ? I still have a doubt if you're suggesting NOT even consider car acceleration, or just don't use it AS IS because it is very stupid (which is obvious ! As you pointed it, even a tire is a kind of suspension on itself). If that is what you mean, then we agree ! Either way, please explain further, the "no calculation" thing. As all front/lateral forces get eventually multiplied by the wheel load, we can say getting the wheel load right is maybe as much or even more important than getting the initial values right. I had much trouble with that, and honestly for this particular subject i kind of miss examples. When i look at a big pickup truck i can see the springs getting highly compressed. Marcos state something like "xxx acceleration > formula > xxx Fz on back wheels, so you accelerate faster". The fact he didn't talked about car suspesions made me think :[list=1] [*]It is not a very important part of the simulation (VERY wrong i think, now) [*]Suspension or no, i CAN get the force he is talking about, eventually, and maybe suspensions will just make the weight shift process a little slower (i guess it is really wrong too). [/list] Here is a problem i still have : if weight transfer is more than a FEW percents, car can spin very easily or behave odd. When i see the raw acceleration weight transfer outputs, i find it hard to beleive spring/dampers can convert a totally incontrolable car in something smooth. So i looked elsewhere.... For a too long time. I mean, will i go from 15% weight transfer to 1% ? Or more from 15% to 12% ? What is a typical cornering car weight transfer values ? On something like a lambo, and a drift car (to have extremes), if i decelerate from 200Km/H to 150Km/H, what can be the front/rear weight repartition at corner entry ? middle ? end ? Is it ok to have almost all cars to spin if the transfered weight ratio from back to front is more than 10% during serious cornering ? (i know you miss the steering and lateral tyres forces intel, but i'm just asking to have an idea of the effect of suspensions). Actually i get pretty good results with 1% ~ 5% maximum weight transfer amount. It all depends of steering and lateral forces, wich varies from one car to an other. --- [quote name='kunos' timestamp='1348840448' post='4984724'] 3. Around 80/100 km/h, understeer with throttle, and oversteer without it. Could be CG too high, too much "coast" torque.. wrong or missing implementation of a proper differential [/quote] I generally have this behaviour too. Slip angle is initially higher at front, it makes the car oversteer (with or without weight transfer). If accelerating, the cornering radius is getting higher very fast (understeering). Even more noticeable if you have an arcade front velocity directly coming from throttle instead of SR/torque. I think (hope) Kunos is right and a differential would help to create a front acceleration vector which has a small angle instead of 0. Thus helping in cornering. I was not confident trying to implement this for now, but i'm looking toward formulas and tips helping to create a diff. Unless the formulas are pure magic, i guess it is very hard to do this quickly. --- [quote name='bmarci' timestamp='1348845115' post='4984742'] Also it would be nice to see some real values, not curves, just sample values eg: (SR=0.01, Fz=3500N, Fx=???) and the same for Fy, just to see if we even have reasonable results. Is there any "healthy" ratio between Fx and Fy (at peak). I just checked, and my FxMax is greater than FyMax. Are these values reasonable for a 255/50ZR16 tyre: Fx: Load=3KN, PeakSR=0.11, MaxFx=3240N, InputSR=0.03, Fx=2211N Fy: Load=3KN, PeakSA=8.6°, MaxFy=2834N, InputSA=4°. Fy=2519N [/quote] +1. We need some real life values with a known-setup car to help us. Do you have the name of a book wich specifically has real examples ? Physics of racing maybe ? --- A few questions :[list] [*]What is a reasonably good lateral deceleration a tire can produce ? I mean, if i am at 50 meters/second front and want to turn right at 90° without making a huge drift, how much lateral G are realistic ? Or in other words what can be the cornering radius ? Reason i am asking this : my game is currently top down, and to see curves, they have to fit on the screen. So, i know my driving environment is far from realistic, and thus i need VERY good tires to turn. So let's say you kick a car lateraly so the Fy speed get instantaneously to 50 meters/s. What would be a reasonable stopping time ? 1s ? 5s ? I have done some research and it seems, F1 car do something like 5G of lateral acceleration, while a regular car is closer to 1G. But no one is trying to take a 90° corner with a regular car at 150 Km/H. I guess if it a crossover it is not even doable even if drifting ? If i have a 1500Kg car, with inertia of 3000 and a pacejka curve like this : peak@4° = 1.2, value@90°=1.0 my car handling is credible, but totally catastrophic, i cannot take any decent corner above 50KmH. I have to go to 20 or more in the 90° to make the car turn ok. [*]Do you see the peak of the long/lat curves as the maximum radius of the traction ellipse in that direction ? [*]Is there a formula to create an ellipse knowing the X/Y radiuses ? [*]If a front pacejka curve is not matching the lateral one : let's say i draw curves by hand and i am modifying them separatly as i try things. Is there a point at wich it is stupid to hope anything because those are so closely related (with SR/SA, traction circles) that everything has to be in perfect harmony (ie: lateral forces physically accurate regarding to front ones). That means i cannot let the player upgrade its front grip without having lateral grip to increase as well ? [*][s]In most car simulations, when the car starts to slide, it acts as it keeps sliding, like if a slide situation was more able to create a slide situation in the next tick. Or like if when sliding has started, the friction forces are modified. That make sense if you consider static/dynamic friction, but afaik, a tire cannot bo seen from this simple perspective. If i am cornering at 150Km/H, i guess everything is sliding here and there a little, and there no such thing as : "static friction, everything is alright"--> "sliding, so i have lost traction and cannot do much about it". But i don't know, we always read the patch is kind of "not moving" at a given time, so maybe even when cornering at high speed, i should consider the patch as static ? And then i would need to find out if it is in static or dynamic friction mode ? No idea if it is a legitimate question, and even less idea on how to determine that.[/s] Funny that jujunosuke had the same hope than me on this ^^ Anyway the response of Kunos is absolutly no static friction. [/list] And finally, last but not least, something very important to me i am still not sure :[list] [*]It is said the more acceleration, the more weight on the tire, and the more weight on the tire, the more grip. So why during intensive cornering, the outer wheels (which are the most loaded) are always the first to slide ? My guess ares : [/list] a) It only happens when the lateral speed gets too high. So something related to static/dynamic friction like i am asking above. And lateral speed would be higher on outside side of the car ? Or even more crazy : in fact all wheels are sliding at the same time, the outside wheels are not always the first to slide in those situations. b) Somehow the slip angles of the outside wheels are getting too high, the curve is getting down and slipping occurs ? c) At some point, more weight means less force ??? I know the weight has diminushing returns on generated forces, it is not entirely linear. But when i looked at the values, even if not neglectible, it does not makes sense that the outer wheels slide first. d) Only happens because of differentials + driver pushing throttle. So outside wheels are slipping, traction circle is outranged and increased weight is not important enough to counter the loss of magnitude of the "raw" lateral friction. e) It is something else, maybe related to camber, or the fact that the car is simply not well balanced with too much weight on one side which means... too strong lateral forces ?
  2. Hello again [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] (i know i have a lot of things to answer in the other topic, but i'm not finished analyzing and trying all suggestions yet !) This subject is very interesting, as i am willing to modelize a proper engine transmission too, eventually. My main concerns are : inertia of components (varying with gear), inner friction and the differential. I am very busy right now working on the purely handling part, so i cant try anything / do suggestions for the moment, but i can give you this link, which is very informative on the subject : [url="http://hpwizard.com/rotational-inertia.html"]http://hpwizard.com/...al-inertia.html[/url] Other cool links on this website : [url="http://hpwizard.com/index.html"]http://hpwizard.com/index.html[/url] But it is quite possible you already have this link in your bookmarks ! Good luck working on that driveline ! I stay tuned.
  3. Well, thanks everybody for the answers, as always, i am still learning interesting things. Edy, i am really glad to see you participating in here, your experience is very valuable. Actually i bought Edy's Car Physics for unity, just to be able to look at car setup parameters and to have a better understanding of some of the mechanics. But with the system based on Unity WheelColliders how it really works is kind of hidden + i have trouble reading spanish comments ^^ Too bad my game is javascript and not Unity ^^ Anyway i have read all of your articles and the interesting comments too. Helpful, but it didn't gave me a real alternative to pacejka curves. To be clear i am working with simple curves plotted for 1N i am scaling afterward. I never messed with those complicated parameters and as pacejka just produce some value, it seems clear it is a very small part of a proper driving game. [quote name='kunos' timestamp='1348759644' post='4984379'] that doesn't make sense at all. deltaT doesnt even appear in a slip ratio definition how can it influence it? There is no reason for a sim to change behaviour if dT is changed, the ENTIRE point of having a dT in the first place is to make things indipendent of time [/quote] Well, it makes a lot of sense to me, actually a lot of articles explain this. Basically if you have 200% slip ratio, and produce 5kN of force for a 50ms timestep, you are stuck with the same force applying for 50ms. With smaller timestep, physics engine actually has a chance to see that slip ratio may have go down to 100% around 25ms, and for the remaining 25ms you will produce a different amount of force for example. You seem to have some experience in car physics (with 2010 posts !), so i guess you already know this and maybe we are not talking about the same thing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Or you have eliminated any numerical instability issue in your simulation and just have forgot about it ^^ Anyway it is not that hard to emulate some equivalent to SR with similar results, but improved stability. My lateral forces are quite stable too at 50Hz, the difference is not really noticeable with 1000Hz. [quote name='Edy' timestamp='1348758851' post='4984376'] In summary, you need these kind of formulas only when developing high-end ultra-realistic vehicle simulation with real tire sets (think on netKar Pro, rFactor, etc). But you are not required at all to use these approaches for developing realistic vehicle physics. These methods are inherited from the automotive industry and it's quite difficult to implement them properly in video games. [/quote] Really ? oO i just learned it. I had the feeling a lot of games (like GTA, or even more arcade games) use the curve approach, even if they tweak it rather than directly implementing the formula. Your framework doesnt seems too much realistic to me, and it's using it right ? I was just plotting simple curves scaled by weight load, and (re)discovered today, that forces do not linearly increase with Fz, thus making proper use of the formula important to me, or at least it is what i was thinking until i read this. [quote name='Edy' timestamp='1348758851' post='4984376'] In my tests I was able to develop a very fun and realistic vehicle simulation using basic vector math only, with the vehicle reacting properly to burnouts, drifting, brake locks... everything in a few lines and running at 50 Hz. [/quote] Oh man, you just blowed up my entire world ^^ just kidding. I know we can have stable behaviours at 50Hz, but having controled/fun drifts over/under steer with really simple maths, without getting into wheel angular vels or SA/SR, and weight-dependant curves seems quite hard to me without recreating this entire logic out of nothing with math hacks or such things. I'd really love to have a look or even be able to buy such a piece of code [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] (seriously). Right now, my best hope to control the drifts without having a naturally oversteering car is to have better load transfer calculations and to stop to apply Fz linearly after normalized pacejka output. Maybe i am once again very wrong to hope that it will greatly improve car handling and capabilities... :'( I have the intuition without a little of weight transfer and some dumb but credible suspension and traction circle or at least combined slips you can't have the driving feeling of your red pickup for example : if i brake enough in a corner i am able to produce controled oversteer to turn sharply at 100Kmh in your 90° curves in the city demo. The best i can do to have "fun" physics with very little code is to directly rotate car and to let the lateral forces of the tire do the rest of the job. Not good enough if i want my player to have car parts and i guess you are suggesting something more sophisticated than this. [quote name='kunos' timestamp='1348759195' post='4984377'] actually the two terms are almost equivalent and, as I said, using body acceleration to calculate load transfer is the wrong way of doing it:) intuition should suggest you that load on a tyre should be influenced by the movement of the tyre, not from the movement of the car body. [/quote] Wow, that is really confusing me. What do you mean by tyre movement ? As in the tire going up and down (spring/suspesion) ? Unless there is a bump in the road, AFAIK, acceleration is responsible for load transfer. Wikipedia is quite clear on this : [quote name="Wikipedia"]In wheeled vehicles, load transfer is the measurable change of load borne by different wheels during acceleration (both longitudinal and lateral). This includes braking, and deceleration (which is an acceleration at a negative rate).[6] No motion of the center of mass relative to the wheels is necessary, and so load transfer [b]may be experienced by vehicles with no suspension at all[/b]. Load transfer is a crucial concept in understanding vehicle dynamics. The same is true in bikes, though only longitudinally.[/quote] Again, when i read what you say and compare it with my "knowledge" of the subject, i can't stop me of thinking i have clearly messed up something... Please enlight me [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [quote name='Edy' timestamp='1348758851' post='4984376'] I'm now developing a new tire simulation model designed form scratch specifically for video games. It provides a complete tire simulation that reacts realistically on almost all possible situations of the wheel, including static friction and wheel spin. I expect it to be completed by the end of this year. [/quote] I'm looking forward to it, but sadly i'd like to have my game runing in alpha stage before that time. And anyway i would still have to rewrite the entire thing in javascript, which i would not be able to do without a lot of detailed english comments everywhere ^^ Actually in my sim everything is fine, except i cannot really combine different behaviours, and it really seem to me everything is VERY weightload related. If i cut a vector using friction circle, it usually makes the car spin very fast. Same goes if too much weight goes to one of the outside front wheels. So have i missed really important things, or am i going the wrong way trying to get more reasonnable load transfer ? I mean if you can achieve credible drifts behaviours without load transfer or lateral pacejka... I'd really like to know where to look to do it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] As always, really looking forward to your answers ! i have spent 6 months reading a lot of docs and trying many things, but i still need to learn A LOT. Main problem is to when you get the basics "right" and it still not fun, is to find out what to try to move forward. I have seen in a lot of threads, a lot of people trying the same things, learning slowly the hard way, to finally give up or be unsatisfied with their car handling. If i get better understanding of the problems and manage to get my car simulation running fine (failure is not option, the rest of the game is going very well), i would be very happy if sharing that knowledge helps future racing developers.
  4. Hi ! Thanks for your answer[u]s[/u] ! Well, indeed it doesn't help that much ^^ Instead of focusing on fun, i know at least a part of the posting people seems to want to have the basic physics right. So knowing if a typical car launched at X velocity should more or less stop in 1 sec or 100 sec might help future beginners to start implementing physics. I know i really had a hard time to get the basics right, and the lack of reference values was a great pain. AFAIK, most of 2D simulations simulates a part of inner 3D (eg : weight transfer), and as long as you consider driving on a flat surface, things are quite similar. For a beginner starting right away with 3D terrain and car model might be a good thing to make stupid mistakes. A few weeks ago i asked if a lateral pacejka force should be applied lateraly to wheel body or to car model, and response was not clear to everyone. A LOT of basics things are not well understood by beginners, and we have a few people here who have successfully created full racing games. So again, i think it might be a good idea to have some shareable and stored knowledge on the subject. As for the "what is fun" part, i guess you are right. But again AFAIK, getting controled drifts and natural car behaviour is kind of what every carsim dev wants,no ?(independant of arcadish/simu considerations) I haven't been able to find very simple and important car setup parameters, so why not trying at least to share those somewhere ? My max_steer function comes from a 3D game and it works well for my 2D sim ;) I really think we can try to bring light to some dark places, instead of always creating topics to ask something precise and then realize a few answers laters that we have missed other things or that we just didn't think of a key feature. Almost all car related topics end like that. And the only tutorials are the one from marco, gamedev and unity, which i personnaly think are really vague on a lot of key subjects like proper car inputs management or how pacejka works. And PHORs is way too complicated for most readers to implement it i guess. I know i do not want to implement the Maths, altough the reading helped me to understand many things. [quote]Probably a 100Hz or 200Hz physics rate should be enough if the car isn't too stiff[/quote] Well, the 1000Hz value in test/dev purpose allow us to be sure any instability does not come from there. Objective of the thread is to try to enlight newcomers to the subject. For a game in early prototype stage, the computer can handle it well. And everyone is free to adapt the value to its needs later, but for the scientifical accurate part, i think 1000Hz is doable and a simple value. [quote][b]Use wheel distance to CG to calculate weight transfer lateraly and longitudinal. Combine those two[/b]. This is most probably wrong... you don't calculate weight transfer, it should be automatically happening in your rigid body physics[/quote] Sorry, i meaned load transfer and not weight transfer, i offen misuse those two words. My dynamic load transfer happens with acceleration in the car body. So to know the real weight on a body point, i have to find out its distance to CG, and then use long/lat acceleration. As i do not use a physics engine (except for the collision detection part), i code weight transfer as much as simple forces integration. So AFAIK it cannot happen automatically unless i use a real 3D engine and feed him with some values. I get front/lat acceleration depending on current acceleration values, which themselves depends on previous ticks generated forces. The real weight transfer, which happens when the car CG is displaced occurs indeed automatically as a suspension or an other is going up or down. I'll edit my post to use correct terms.
  5. Hi again to everyone I noticed we are now at least 3 on this forum, trying to create a proper car simulation. It seems everyones main goal is to create something fun (drifts...), based on realistic physics, but not too hard for the player. So closer to something like GRID than Forza. I think i am right when i say this : we all want the kind of fun we can find in games like NFS. If a game like NFS or GRID (or even the Steam racing casual games) can only be achieved by using some cheats or specific player input tweaking, i suppose we all want to know what they are. What i propose here is :[list=1] [*]Share the fundamental basics every car simulation based on newton physics should have. eg : weight transfer, pacejka-like curves for getting output of SR/SA.... [*]Share one or two basics car models and parameters to be sure we are talking about the same thing. [*]Share some reference values/behaviours in predetermined situations, so that everyone can compare their own values with some reference to know if things are going right or wrong. [*]Share math/physics formula, tips & tricks, or cheats & shortcuts that would allow us to make the game more fun. Because we must not forget, it is all about fun in the end. [/list] I would try to maintain the first post as updated as possible as people bring their contributions. So if this thing is going well, it could be a very good starting point in the future for programmers wanting to create their own car simulation. I'll start to fill the blanks, and i hope the car experts will bring their knowledge to be sure future readers won't be misleaded by the things listed here. One of the goals here is to cover 2D and 3D games, as the car behaviour will be similar in both situations. [size=5][b]Part 1 - What should i absolutly do to make this a fun game with drifts, skids and such things ?[/b][/size] Let's make an exhaustive list of things needed to achieve a drifting behaviour on a racing car.[list=1] [*]Get [b]basic newton physics[/b] right : forces, acceleration, torque, integration. You can use a physics engine for this, like box2d or PhysX. [*]At first use a [b]1ms timestep[/b] to update the simulation at a decent rate and avoid bad approximations. [*]Create [b]4 wheels and attach them[/b] to the body. [*]Use wheel distance to CG to [b]calculate weight transfer lateraly and longitudinal[/b]. Combine those two. [*]Use [b]real car suspension/springs/anti roll bars[/b], or the weight transfer will just be instantaneous and make the car highly unstable. Subsidiary question : is it vital to have proper car suspensions ? [*]Use some [b]"soft" player inputs, and try to limit steer angle[/b] at high speed to get good lateral forces, or the car might be totally uncontrolable. Or use realistic driving accessories. [*]Find out [b]velocity for each wheel contact patch[/b], transformed in the wheel space. So if the wheel is heading 45° and the car going straight, the front wheels will have both X/Y velocities, as rear wheels will only have Y (if Y is front). [*]Use the powered wheels velocity to [b]determine motor RPMs[/b]. Based on player throttle input, and engine torque curve, [b]generate a torque force for powered wheels[/b]. [*][b]Apply torque on wheel so it increase their angular velocity.[/b] [*]Calculate wheel [b]slip angles[/b] and [b]slip ratios[/b]. [*]Use a plotted [b]pacejka curve[/b], or a real formula to find out the normalized force the tire must produce front/lat. Subsidiary question : is it vital to have the original formula instead of a simple pre-plotted curve ? Subsidiary question : is it vital for nice drifting to have combined lateral/front formula ? Subsidiary question : is it vital for nice drifting to feed directly the real load to the formula ? If i multiply the normalized 1N value by the wheel Fz result is supposed identical right ? [*][b]Create a vector for front/lat forces[/b], and [b]check this vector on friction circle/ellipse[/b]. Cut any part which is not inside the circle. Subsidiary question : should ellipse max values be the same as pacejka normalized max values ? [*]You can now [b]multiply the remaining vector by the wheel weight[/b] (Fz) [*]For the [b]longitudinal component[/b] of the force, reintegrate it in the wheel (with the radius), so it [b]decrease their angular velocity[/b]. That part is what makes the wheel angular velocity adapt to the car speed. [*]Apply [b]the resulting forces to the body[/b], at the attach point of the wheel, or directly the contact patch in 3D, and calculate resulting torque/acceleration on the body. [*]When 4 wheels have generated torque/forces for the car body, [b]integrate those values in the physical[/b] engine to produce velocity and move the car. [*][b]Apply damping forces (rolling friction, air drag)[/b]. It is not supposed to be vital to car behaviour, but it might help a little. It will mostly influence acceleration time and maximum speed. [/list] That should be all what is needed to get a car simulation right. At least theorically. I think i have forgotten nothing. [size=5][b]Part 2 - The reference car(s)[/b][/size] The goal of this part is to have reference values for a classic car, so we can compare our values and behaviours. The classic car inspired from some Corvette C5 values and other frequent values seen here and there. Let's call it X-Car-1 [spoiler] [CODE] /** GENERAL BODY CONFIGURATION **/ // Length of the car (m) body_length = 4.57; // Width of the car (m) body_width = 1.87; // Mass of the car in Kgs body_mass = 1500; // Inertia of the car // Rectangular box inertia formula is : (mass * (boxWidth² + boxLength²)) / 12 --- (height doesnt count) body_inertia = 3000; /** WHEEL ATTACH POINT AND STATIC WEIGHT DISTRIBUTION **/ // Vertical distance from front axle to gravity center horizontal line (if car is heading vertical) geometry_frontAxleDistanceToCG = 1.60; // Vertical distance from rear axle to gravity center horizontal line (if car is heading vertical) geometry_rearAxleDistanceToCG = 1.60; // Horizontal distance from any wheel attach point car vertical middle line geometry_wheelDistanceToCarCenter = 0.80; // Height of the CG (in meters) geometry_heightOfCG = 0.30; /** ENGINE SETUP **/ // Values of the power curve for each RPM engine_torquePowerCurveValues = [ 400, 430, 448, 460, 480, 486, 480, 500, 550, 500]; // Values of the RPMs for the power curve engine_torquePowerCurveRPMs = [1000, 2000, 2500, 3000, 4000, 4500, 5000, 5500, 5800, 6000]; // Used in dev to quickly enhance engine power by a flat multiplier engine_torquePowerCurve_multiplier = 1; // RPMs at wich the driver should shift up engine_shiftUpRPMs = 5800; // RPMs at wich the driver should shift down engine_shiftDownRPMs = 3000; // Some values used to slow down car engine when no throttle is applied engine_brakeCurveValues = [ -40, -40, -50, -60, -70, -80, -100]; // The RPM values engine_brakeCurveRPMs = [ 1000, 1050, 2000, 3000, 4000, 5000, 6000]; // Used in dev to quickly enhance engine brake curve effect by a flat multiplier engine_brakeCurve_multiplier = 1; // The gear ratios of the gearbox engine_gearRatios = [-2.90, 2.66, 1.78, 1.30, 1.10, 0.96, 0.80]; // The differential ratio (between gearbox output and motorized axle input) engine_differentialRatio = 3.42; // Efficiency of power transmission engine_transmissionEfficiency = 0.7; // Ratio of power going to rear axle (1 means 100%) engine_rearAxlePowerRatio = 1.0; // Ratio of power going to front axle engine_frontAxlePowerRatio = 0.0; /** WHEELS SETUP **/ // Time in seconds to reach max steering angle wheel_steerSpeed = 0.500; // Maximum steer angle when the car is stopped/low speed (in radians !) wheel_steerAngleMax = Math.PI / 4; // If setted to yes, the driver will not be allowed to steer to much at higher speed wheel_optimizeSteerAngle = true; // Adjusts autosteer level, from 0 to 1 : 1 will be perfect knowledge of actual cruise speed wheel_optimizeSteerAngleValue = 1.0; // Bonus : autosteer formula | max_steer = Math.min(maxSteerAngle, Math.PI/2 - Math.acos(peakLateralSlipAngleInDegrees / absFrontSpeed)) // Inertia of the wheel // TODO : it should depend of the actual gear but i have no formula for it wheel_inertia = 25; // The radius of the wheel (in meters) wheel_radius = 0.33; /** FRONT FRICTION FORCES SETUP */ // The front pacejka curve values for a load of 1N (for slip ratio output) friction_front_longitudinalPacejkaCurve_valuesFor1Nload = [0, 1.00, 1.20, 1.30, 1.20, 0.90, 0.70]; // The front pacejka curve slip ratios corresponding to the above force outputs friction_front_longitudinalPacejkaCurve_slipRatioValues = [0, 0.01, 0.03, 0.05, 0.10, 0.20, 1.00]; // Used in dev mode to multiply pacejka output for testing purposes friction_front_longitudinalPacejkaCurve_valuesMultiplier = 1; // The front pacejka curve values for a load of 1N (for slip angle output) friction_front_lateralPacejkaCurve_valuesFor1Nload = [0, 0.10, 0.20, 0.30, 0.41, 0.49, 0.58, 0.66, 0.73, 0.80, 0.87, 0.92, 0.97, 1.01, 1.05, 1.08, 1.11, 1.13, 1.14, 1.15, 1.16, 1.15, 1.10, 1.03, 0.94, 0.79, 0.66, 0.55, 0.50, 0.46, 0.39]; // The front pacejka curve slip angles corresponding to the above force outputs friction_front_lateralPacejkaCurve_slipAngleValues = [0, 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00, 20.00, 25.00, 30.00, 35.00, 40.00, 50.00, 60.00, 70.00, 75.00, 80.00, 90.00]; // The slip angle for which you get maximum force friction_front_lateralPacejkaCurve_slipAngle_peakGrip = 20; // Used in dev mode to multiply pacejka output for testing purposes friction_front_lateralPacejkaCurve_valuesMultiplier = 1; // The front traction ellipse longitudinal friction limit friction_front_longitudinalLimit = 1.30; // The front traction ellipse lateral friction limit friction_front_lateralLimit = 1.30; /** REAR FRICTION FORCES SETUP */ // The rear pacejka curve values for a load of 1N (for slip ratio output) friction_rear_longitudinalPacejkaCurve_valuesFor1Nload = [0, 1.00, 1.20, 1.30, 1.20, 0.90, 0.70]; // The rear pacejka curve slip ratios corresponding to the above force outputs friction_rear_longitudinalPacejkaCurve_slipRatioValues = [0, 0.01, 0.03, 0.05, 0.10, 0.20, 1.00]; // Used in dev mode to multiply pacejka output for testing purposes friction_rear_longitudinalPacejkaCurve_valuesMultiplier = 1; // The rear pacejka curve values for a load of 1N (for slip angle output) friction_rear_lateralPacejkaCurve_valuesFor1Nload = [0, 0.10, 0.20, 0.30, 0.41, 0.49, 0.58, 0.66, 0.73, 0.80, 0.87, 0.92, 0.97, 1.01, 1.05, 1.08, 1.11, 1.13, 1.14, 1.15, 1.16, 1.15, 1.10, 1.03, 0.94, 0.79, 0.66, 0.55, 0.50, 0.46, 0.39]; // The rear pacejka curve slip angles corresponding to the above force outputs friction_rear_lateralPacejkaCurve_slipAngleValues = [0, 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00, 20.00, 25.00, 30.00, 35.00, 40.00, 50.00, 60.00, 70.00, 75.00, 80.00, 90.00]; // The slip angle for which you get maximum force friction_rear_lateralPacejkaCurve_slipAngle_peakGrip = 20; // Used in dev mode to multiply pacejka output for testing purposes friction_rear_lateralPacejkaCurve_valuesMultiplier = 1; // The rear traction ellipse longitudinal friction limit friction_rear_longitudinalLimit = 1.30; // The rear traction ellipse lateral friction limit friction_rear_lateralLimit = 1.30; /** DRAG FRICTION FORCES SETUP **/ // The air drag value, wich is multiplied by speed² // Bonus : air drag formula // AIR_DRAG_FORCE_CONSTANT = 0.5 * Cd * A * rho // Cd = coefficient of friction > depends on the shape of the car and determined via wind tunnel tests (Approximate value for a Corvette: 0.30) // A is frontal area of car > approx. 2.2 m2 // rho (Greek symbol )= density of air > 1.29 kg/m3 // AIR_DRAG_FORCE_CONSTANT = 0.5 * 0.30 * 2.2 * 1.29 = 0.4257 friction_air_drag = 0.4257; // The rolling friction value, wich is multiplied by speed (applied blindly in X, Y) friction_roll_drag = 15; /** CAR SUSPENSION SETUP **/ // TODO : implement real car suspensions // Flat front/rear weight transfer division suspension_frontRearWeightDisplacement_divider = 2; // Flat lateral weight transfer division suspension_leftRightWeightDisplacement_divider = 4; // Time for a new load value to be fully applied in milliseconds suspension_timeToReachForce = 1500; [/CODE] [/spoiler] To be honest i must say this reference values don't make a nice car. I'll post a general handling video soon. Here are some parameters taken from [url="http://www.edy.es/dev/vehicle-physics/live-demo/"]Edys Car Vehicle Physics[/url] for the Red Pickup you can try in the demo. Some of the values can be monitored with B and the SHIFT+B in the demo. I post it here to give some elements to discuss about as a part of those values are not present above, and for some i just dont know what they mean. Any idea / insight would be appreciated. [spoiler] [img]http://imageshack.us/a/img842/1227/edysphyicsparams.jpg[/img] [/spoiler] [b][size=5]Part 3 - Reference handling and values[/size][/b] The goal of this part is to put the car in a typical situation with controlled environment, and to look at what happens. Game may be written in Java, .NET, Unity or whatever, if you have taken control of the physics, and if you have the right car parameters, the values should look like these. [b]X-Car-1_T01[/b] : apply 100% throttle for 10.00 seconds Coming soon... [b]X-Car-1_T02[/b] : launching directly the car with a front velocity of 50 meters/s Coming soon... [b]X-Car-1_T03[/b] : launching directly the car with a side velocity of 50 meters/s Coming soon... [b]X-Car-1_T04[/b] : launching directly the car with an angular velocity of 10 radians/s Coming soon... [b]X-Car-1_T05[/b] : launching directly the car with a combined front/lateral velocity : 50m/s in each direction Coming soon... [b]X-Car-1_T06[/b] : launching directly the car with a combined front/lateral velocity : 50m/s in each direction and a 10 radians/s angular velocity Coming soon... [b]X-Car-1_T07[/b] : apply 100% throttle for 10.00 seconds, then without releasing throttle, press the right key for the next 10.00 seconds (right + full throttle) Coming soon... [b]X-Car-1_T08[/b] : apply 100% throttle for 10.00 seconds, then release throttle, and press the right key for the next 10.00 seconds (right + free roll) Coming soon... [b]X-Car-1_T09[/b] : apply 100% throttle for 10.00 seconds, then apply brake, and press the right key for the next 10.00 seconds (right + brake) Coming soon... [b]X-Car-1_T10[/b] : a controled drift situation (still have to find a reference test) Coming soon... [b][size=5]Part 4 - Tips & tricks[/size][/b] This part is still R&D, and i am more open to debate and wanting to collect ideas and tests than trying to explain to do this or not. I do not have the solution for doing most of those things anyway. List of "legit" tricks :[list=1] [*]Limit maximum steer angle according to speed & max grip peak SA [*]Same for throttle/brakes with peak slip ratio output [*]Decrease gently (or not) steer angle after input release [*]Be aware (you, programmer) of when a drift situation occurs and change car control inputs to help player have more fun [*]Instead of modelizing a complex combined front/lat grip formula, just determine how much percent of lateral grip you lose in function of the slip ratio [/list] Cheap tricks or cheats :[list=1] [*]If player apply throttle, just directly add front Y velocity to car [*]Disable real front/rear weight calculations. Just decide of a prefixed weight change on acceleration/braking situations [*]Gently decrease forces near/after traction circle max value, instead of just cutting it [*]Rotate directly car velocity vector by a very small percent of the front wheels slip angle [*]Use a linear slipAngleInRadians * someConstant formula for lateral pacejka output [/list] [b][size=5]Part 5 - Reference formulas and ressources[/size][/b] More content to come... Reference physics formulas, tutorials and references... [b][size=5]Part 6 - Questions, FAQ, things we don't know[/size][/b] [b][size=4]Questions :[/size][/b][list=1] [*]What is the formula to have a friction ellipse instead of a circle ? [*]Where can we find a simple formula for combined long/lat grip ? [*]Should we apply a static friction force or something like that or just pacejka ? [/list] [b]FAQ :[/b][list=1] [*]Should i apply forces lateraly to car body or to the wheel ? To the wheel. [*]More classic question and answers to come... [*]What value can i use to decide if i must draw lateral drift skidmarks ? [*]What value can i use to decide if i must draw burnout skidmarks ? [/list] I am a little bit tired, but i will update with more basics. I'm looking forward to read your answers and contributions, if anyone interested !
  6. Hi everyone. I have read this very closely as i have my issues with my own car sim. (So now we are at least 3 guys needing help ^^) I agree with kunos, you can have the same behaviour with different parameters. For example you can have oversteer if you accelerate during cornering and outrange the traction circle on rear wheels. But the weight transfer created by the acceleration can add more weight to the back of the car and thus, produce understeer. Depends of settings i guess, or maybe i missed something again. [CODE] Vector3 lateralForce = this.transform.right * pacejkaLateral; this.rigidbody.addForce( lateralForce ); [/CODE] If the body is the wheel, i do the exact same thing. My sim is not perfect (far) but it seemed ok for basical handling. [quote name='kunos' timestamp='1348635065' post='4983882'] For sure I see a problem in your code, you are adding the lateral force at the wheel center and not at the wheel contact point, this is clearly wrong, and one of the effect would be to reduce lateral weight transfer left/right. Also the "right" vector of the tyre isn't the right direction for the lateral force that is generated on the plane of the road.. if you add it like that, the force will start to point "up" as the car rolls, this is wrong and will reduce load, thus grip.[/quote] [b]At the wheel center and not at the wheel contact point[/b] > I know you're talking about 3D sim, but mine is 2D. So lateral force is just lateral force, applied at the wheel attach point, as it cannot more on ground than on wheel center, and i already have a LOT of lateral weight transfer, i have to limit it. My lateral transfer is calculated by me using lateral acceleration provided by total lateral forces on the body. I don't really understand the implications of that phrase for a 2D sim. [b]"right" vector of the tyre isn't the right direction for the lateral force that is generated on the plane of the road[/b] > Again i have trouble to understand what you mean. You mean if the contact patch is at some inclination, the lateral force should respect this patch position ? If it is it, again in 2D, i am not concerned directly. [quote name='kunos' timestamp='1348635065' post='4983882'] The behavior you explain in your first post is not necessarily wrong , a well balanced car will not spin out... [/quote] Well it makes me think, probably none of us has a really good model of a "well balanced" car. At least i have read nowhere : "this is the data of a fun drift car", and "this is the data of some nice stable car". If jujunosuke & bmarci agree with that idea, maybe we could start to share a model with preset parameters which could help us to understand what we are doing right, and what we are doing wrong [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [quote]Also, i forgot to mention that there is no weight transfer in my simulation, the load on the tire is always the same. That may explain also some issue i have.[/quote] I would say yes. I can do some extremely fast spins with weight transfer activated (front/rear). I suggest you try to activate it and see if braking + steering allows for a fast car spin. If it is extremely fast and uncontrolable drifts, well you might have reached the same point as bmarci and me ^^
  7. Hi, bmarci ! I apologize for the long response time, but unfortunately, despite my best efforts, i had not that much interesting answers to bring. The best progress i made so far was realizing front/rear weight transfer is mainly responsible for indesirable/strange behaviours. Not a great improvement... At least i worked a lot on it, and cleaned a lot of things and started a better file configuration, and added simultaneous right/front weight transfer. Lateral weight transfer helped a lot in some situations. [quote name='bmarci' timestamp='1347959888' post='4981185'] Yes, I made a speed sensitive steering which seems to work fine until some heavy intervention is needed, so if my car starts to skid my steering doesn't let me to counteract because of the high speed, and there is only 2-3° of max steering available. [/quote] I have kind of the same issue. Maybe simply allow counter steering to go as far as player wants ? I was thinking of something more controled in case of counter-stering / drifting. Like preventing the player from spinning voluntary while cornering. [quote name='bmarci' timestamp='1347959888' post='4981185'] I use lateral pacejka. The mentioned uncontrollable situation occurs without my special addition. Earlier I added an extra Vel_long-=wheel_roll_vel; to the contact patch velocity calculation (only for slip angle) since the wheel rolling also affects the contact patch's velocity. So with that little extra the car is very stable at least on a straight move with lane changes. Maybe it's an "arcadish" tweak for better handling, but without it I have hard time having the car move on a straight line after a little direction change (A simple overtaking is a great challenge, the car is moving off the road and it's a pain in the ...... -somewhere- to put it back on the road again.) [/quote] I don't really understand your arcade tweak. But if the car don't want to go straight after a turn, you can try to remove the front/rear weight distribution or tweak a little side weight repartition. I have this issue sometimes because of strange weight balance. [quote name='bmarci' timestamp='1347959888' post='4981185'] I made a quick force calculations on lateral traction vs. weight transfer; (and noticed some weird result values, see later) No weight transfer: (steer angle=1°) Fz_left=3kN Fy_left=937N Fz_right=3kN Fy_right=937N That's 1874N total lateral force on the front wheels. With weight transfer, same steer angle (75%R 25%L) Fz_left=1.5kN Fy_left=970N Fz_right=4.5kN Fy_right=745N That's 1715N total lateral force which would mean the lateral weight transfer is bad to the stability??? Also my pacejka curve looks good when I display it, but in the last values more load generates less lateral force? I don't get it. Is that normal? Could you check it with your formula?[/quote] I don't directly use the pacejka formula, instead i plot a curve with values. The curve i currently use is the one KJM gave above. So back to your question. Yes you have less response force in the end of the curve, despite maybe higher load. You can consider pacejka curve and weight influence separatly. You can simply give 1N to your formula, get an output and finally multiply by the weight. So with less weight you can get higher forces if the slip angle is ideal. But ! for 90° slip angle for example, you should always get more force as you add more weight if the slip angle is still 90°. Unless i missed something. The lateral weight repartition is a good thing if there is not too much and enough. If i have only lateral weight transfer without front/rear, it improves greatly stability, but i am not able to start drifts or to corner faster with controled oversteer. Unless my car naturally produce this oversteer. [quote name='bmarci' timestamp='1347965920' post='4981197'] The error in my theory is probably somewhere at the two wheels don't have the same slip angle at steering[/quote] You mean the two front wheels ? Mine have almost the same slip angle, but it cas vary a little depending on angular velocity for example. Not sure about what you mean ^^ [quote name='bmarci' timestamp='1347965920' post='4981197'] I just got an idea: Maybe it's time we started using the aligning moment (Mz) from our favourite Pacejka formula [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I'll try to integrate it into the simulation, so if everything works as I expect the wheels should go back to 0° when I let loose the steering wheel (when moving). And maybe use steering torques as the drivers hangs on the steering wheel [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] and thus at the peak moment the steering and aligning forces should cancel each outher out. Does it have any sense or absolutely pointless? I added mouse steering, so any steer angle can be produced instantly. Very unconfortable, but the skidding is much more controllable. [/quote] It is intereseting idea, as i understand it this value can be used to produce response forces in racing driving accessories. Maybe you can use it, but i really dont know if it will improve car handling or drift situations/controling. Not a clue, but my guess would be to improve steer control first or to continue experimenting with your mouse until you can do some nice controled drifts. [quote name='bmarci' timestamp='1347978787' post='4981265'] An other note about stability. Since my car has 60% load on the rear axle, I played with the pacejka coeffs for the rear wheels so now they produce more lateral traction and thus more stable and eliminated the sudden oversteer, just a bit more grip as you mentioned. BUT! Now I cannot skid, not even with handbrake, also donuts work only with nose-weighted cars. So now I have almost everything but they don't work together. If I reduce grip on the rear tyres I can make the parking-lot-show-off-manouvers but cannot take the first corner on the track. Soon I'm gonna be out of ideas. [/quote] We are at the same point my friend. I can have all behaviours separatly, but it is more a car which always have this behaviour than a regular car able to drift, etc. + i really offen have sudden car spins, or car starting to roll backward in a turn easily if i try to drift with a "normal" car. I am not out of ideas, but i am very tired to try things blindly. I think we really need an insight to see which parts of our simulations should be improved to allow for controled drifts with a car which is not naturally oversteering. Weight transfer is really the thing that seems to have the more influence here. I just integrated front/rear & left/right at the same time, but when i do long turn, at some point the front outside wheel get the highest weight load (while inner rear has the lowest), and then my car spins immediatly. In fact, all my control loss situations and so do make a lot of sense with regards to physics, the problem is not preveting them but making them fun/controlables. The real problem i almost always have is : when i lose control, instead of starting a controled/credible drift situation, car almost always spins immeditatly, which seems really unrealistic. I feel like i should had some kind of "static lateral" friction which would always be there or something like that i may have missed. I use pacejka forces and nothing else, maybe should i ? If i have a naturally overseering car, it really feels like i am driving on ice, but i have controled drifts situations. Also, i always need to multiply my normalized (for 1N) pacejka lateral output. If i get 1100N force for 1000N load @20° slip angle for example, my car is really on ice. I need to multiply by 5-10 to be able to turn at 100-150 kmH. I guess it is not normal right ? The car weight is 1500 kg.
  8. Hi ! I'm glad to read an answer to my topic So i guess the new subject is "how to make it both physics-based and and fun", eg : have some sort of NFS cornering style. Or at least GT with a very controlable car. [quote name='bmarci' timestamp='1347874246' post='4980823'] The Pacejka MF, takes KILO NEWTONS as input load, so your 1N is actually 1000N! [/quote] Thanks for the precision [quote name='bmarci' timestamp='1347874246' post='4980823'] I was twiddling with stability and controlled drifting and such in the weekend and realized that the weight transfer has significant importance in cornering and control, which makes sense, but also confuses me why anti-roll bars help stabilizing in corners [/quote] Yes, i realized the same thing. I have come to the conclusion that physics-based car SHOULD implement some sort of weight transfer, as ultimately every force get scaled by weight transfer. For anti-roll bars, their main effect should be to prevent the car to roll in high speed cornering ; in 3D physics, if you generate a lot of lateral forces during cornering, the car inertia makes it want to roll : http://www.euclideanspace.com/threed/games/examples/cars/cornering/car2cornering.png I think from a 2D point of view, that anti-roll bars will help to prevent too much weight to go left/right of the center of mass during cornering too, which can have some effect in tires grip. Altough, i have read, lateral weight transfer is generally a good thing, as it gives more grip to the tires who needs it. But it must become a bad thing past some critical ratio value i guess. What i can tell you is what i know (almost) for sure abour car control. In a so primitive state as we are, the things that would tend to have the more effect on the driving feeling would be :[list=1] [*]The wheel friction (long/lat, etc) [*]The wheel springs (weight repartition entirely relies on them) [*]The control system intelligence (without intelligence even a very fun/arcade car might be unplayable without very carefull throttle/steering management from the player) [/list] I feel like we are more at step 1. Successfully going to step 2 might be quite complex, and maybe we should do some arcadish algorithms to handle weight transfer and its effects the way we want it before blindly implement yet another "real life" physics formula. I realized those past days that input post-analyzing is maybe even more critical that correct lateral/long forces implementation. If you look at almost every car game, at high speed the wheel is steering of 2-3° against 45° at very low speed. Some games calculate the peak of lateral grip to prevent the player from going besides grip peak. Same goes for front/brake inputs. It's not ESP or anti lock system at this point, it is more like the driver "listenening" to what the car he is sitting in has to "say". I'll try to come up with some formula to calculate max steer angle in real time to see how much it helps during cornering. [quote name='bmarci' timestamp='1347874246' post='4980823'] Without weight transfer my car was incredibly unstable at high speed (>100km/h), even with a very small (2-3°) steering angle it spun around instantly. [/quote] What kind of lateral friction do you apply ? Because i tend to have some sort of controled lateral drift quite easily with : a) no weight transfer b) a linear force returned for cornering forces : slipAngleInRadians * 5 for example (with a 1500kg car, so it is around 3500N for each tire) [media]http://youtu.be/z_6tRGwShFE[/media] I shooted this video to show you what i am saying. Without weight transfer, i tend to have this behaviour when the lateral forces curves & weight load are == for the 4 wheels. With "real" pacejka curve, i get a lot of understeer after the peak, so i have to limit the steer angle of the wheel. Sorry for the low framerate it is actually smooth and nice to see (no teleporting). I'm recording with VLC which gives me a not that good framerate. --- Adding rear/front (no lateral) weight transfer i get :[list] [*]Great instability if turning + braking. Note that braking occur naturally because of front wheel lateral friction, "natural" air/roll friction, + eventually real driver input braking. Anyway, my car spins really fast even with a very small amount of weight transfered from the rear to the front. [*]Increased understeer effect during high speed cornering, especially if i do not limit steer angle. [*]Theorically controled drift could happen, but in reality car spins way too fast for the driver to have any time to react. Even in slow motion, if you have time to react, the situation evolves too quickly. But the physical facts & consequences are not illogical to me. [/list] --- I don't know if my experience is helping or confusing you. (helping, i hope). I remember using 5% more traction (linear *1.05 multiply) for front or rear wheel train, successively. More grip to rear = understeer and more grip to front = oversteer. Nice to play with without weightload, but as soon as weight get transfered it makes turning even more catastrophic. My intuition here tells me, the great yaw velocity comes from the lack of balance between front/rear tires lateral response. *1 or *10k is not very important as long as everything scales at the same time. If the lateral force balance comes to F70%/R30%, for example, the car will do spin turns very fast. When i analyse those ratios at the times the car seems to be in a small oversteer situation (which is a feeling players tend to like), the front wheels quickly (almost instantly) goes from 90% to 51% of the total generated lateral forces in early cornering. If you want to prevent the car to spin, the lateral force of the rear wheel must quickly go over 50% to keep the car heading controllable (in the above video example, the rear wheels go to 51% of the total lateral force generated to "counter" oversteer). So, looking at the problem from this perpective might help you to adjust parameters to stabilize things. It helps me to think clearly at "what i want", anyway. I know we can use different traction circles/curves for front/back tires, but i have seen very nice drifting behaviour in Edy's car physics which seemed to apply the same curves for every wheel. So i would (will) try to get drifing whithout messing with this for now. --- Actually i am wondering if lateral weight transfer could greatly influence the wheels in the outside of the turning lane, in a maner that would add more stability to car yaw, and eventually help us to get a nice turning feeling. What is your feeling about this ? --- [quote name='bmarci' timestamp='1347874246' post='4980823'] Adding some load transfer helped, but it was still oversteer without throttle. With throttle it was just understeer, but no inbetween... So I cannot play with brakes and throttle to control drifting [/quote] Same thing here. Worse : if i try to limit traction circle to have throttle/braking to allow for controled drift, i go from normal high speed understeer (due to high speed, despite small deceleration) to instant oversteer because throttle consume too much traction budget. I have the feeling i want the 100% operating range of my drifting to be limited to a very small range of force difference. Looking at Edys vehicle physics curves in real time, i learned you can saturate front wheels without starting to spin instantly. I still have to figure out if that is dued to springs, more complex formulas, or to input control and magic things. --- [quote name='bmarci' timestamp='1347874246' post='4980823'] My weigth transfer formula is: W=m*GRAVITY Wf=(c/L)*W-(h/L)*Fx Wr=(b/L)*W+(h/L)*Fx [/quote] Here is mine , it looks to be the exact same. Anyway, weight transfer is quite easy to check from real life data available on internet. The problem does not lie in the raw calculations rather in the fact that spring must have a great influence on that, too (i guess). [spoiler][CODE] updateAxleLoad = function (forwardAcceleration) { var newWeightLoad = 0; // Gravity center height var cgHeight = this.car.cg.h; // Distance between front/rear axle var distanceBetweenAxles = this.car.cg.b + this.car.cg.c; // Distance between actual wheel and gravity center // TODO : calculate REAL distance (wheels are not centered in axles, rather on the car sides, so we should use pythagore) var distanceToCenterOfGravity = 0; if (this.wheelId == WHEEL_FRONT_RIGHT || this.wheelId == WHEEL_FRONT_LEFT) { distanceToCenterOfGravity = this.car.cg.c; } else if (this.wheelId == WHEEL_REAR_RIGHT || this.wheelId == WHEEL_REAR_LEFT) { distanceToCenterOfGravity = this.car.cg.b; } // We need ratio cgHeight/distanceBetweenAxles to calculate mass transfer var h_by_L = cgHeight / distanceBetweenAxles; // Mass of the car var totalCarMass = this.car.m_mass; // Planet gravity var NEWTON_GRAVITY_CONSTANT = 9.81; // Weight of the car on the planet var totalCarWeight = totalCarMass * NEWTON_GRAVITY_CONSTANT; // Static wheel load (without acceleration) var staticLoad = (distanceToCenterOfGravity / distanceBetweenAxles) * totalCarWeight; // Dynamic load due to car acceleration var dynamicLoad = h_by_L * totalCarMass * forwardAcceleration; // Taking care of acceleration sign for weight increase/decrease if (this.wheelId == WHEEL_FRONT_RIGHT || this.wheelId == WHEEL_FRONT_LEFT) { // Front wheels get less weight with more front acceleration newWeightLoad = staticLoad; - dynamicLoad; } else if (this.wheelId == WHEEL_REAR_RIGHT || this.wheelId == WHEEL_REAR_LEFT) { // Front wheels get more weight with more front acceleration newWeightLoad = staticLoad; + dynamicLoad; } // The weight was for the axle, now we devide it by 2 for individual wheel weight this.m_weightLoad = newWeightLoad /= 2; [/CODE][/spoiler] --- [quote]For 4 wheel weight transfer, I'm not sure if this is the right thing to do: Just transfer along axles based on lateral acceleration. Fz_front_left=0.5*Wf+(h/Track)*Fy Fz_front_right=0.5*Wf-(h/Track)*Fy ...the same for the rear wheels...[/quote] I was going to do the same thing. You can indeed get lateral weight transfer the exact same way you get front/rear. The problem is you have 2 differents values for 4 wheels, so it is 8 values. How do you combine that ? I was thinking about this : For example :[list] [*]static load = 3500N / wheel [*]front/rear load = 4000N front / 3000N / rear (decelerating) [*]left/right load = 5000N left / 2000N right (high speed turning) [*]i think we SHOULD take care of angular velocity in lateral weight transfer, but i haven't looked into it. [/list] So, laterally 42% of weight goes from right to the left. And 15% of the weight goes from rear to front. I would say it give me for the different tires :[list=1] [*]FL : 3500 + 3500 * (+0.42 + 0.15) = 5495 [*]FR : 3500 + 3500 * (-0.42 + 0.15) = 2555 [*]RL : 3500 + 3500 * (+0.42 - 0.15) = 4445 [*]RR : 3500 + 3500 * (-0.42 - 0.15) = 1505 [/list] Total weight = 14.000N, so =3500*4. I think this way the weight is what it is supposed to be. In my example, i have way more lateral acceleration than front deceleration, so the outside wheels should get way more grip with some oversteer due tu front having more traction. I think those weight repartition values would produce very unstable car (yawspins), but i'll try it anyway. --- [quote]Adding some jacking force helps a bit, but still not the result I expected. F_jack=Fy*h_roll_center/(Track/2) Fz_front_left-=F_jack Fz_front_right+=F_jack h_roll_center = roll center height from ground[/quote] I'm not entirely sure how/why it helps, what do you mean by jacking force exactly ? I know it has something to do with suspension, but i havent really looked into in ATM. I tried to divide weight transfer valye by 250, 500, 1000 to simulate "time to reach the calculated weight", it helps, but still, weight transfer has dramatic effects on behaviour. --- [quote]Maybe I'm mixing up things, or should I implement a proper suspension model, where all spring and dumping forces do all the weight transfer and the formula above is not needed at all?[/quote] I really don't know, and i really want to know ! As i said, suspension seems to be a critical part of how a car can be handled. --- [quote]I was also playing with car settings, and it seems a front engine car (60:40 weight balance to the front) is more controllable than a mid-engined (40:60) which should not be.[/quote] Be sure you are using the proper wheel distance to CG. If i have more weight to the front, the car easily align the front in the turns. Even when CG is only closer to front of a few cms, the effect is immediatly noticeable. As with traction, even a few % changes have great consequences. AFAIK, front engine cars are easier to handle, as they can easily turn compared to rear-mounted engines car which can be tricky to handle during oversteer situations as the back of the car want to go to the front (easier car spins). So i guess you're experiencing something which is good. But with unstable car turning due to a few % changes in repartion of mass, if you are braking with a front mounted engine, you will obtain even wore oversteering. --- In facts, all those things leads me to think that my main problem is the effects so small ratios changes are producing. Dramatical effects. Everything should be WAY more stable even with poor wheels/suspensions systems. So the right question is what should i do (maths shortcut or real physics) to improve my car stability... ? My currently strategy is :[list] [*]Intelligent analysis of player inputs (ideal max steer angle/throttle ...) [*]Gently decreasing force when coming closer to traction circle edge (when i'll re-introduce it) [*]Try lateral weight transfer to if it improves/worsens car handling during high speed turns [*]Maybe add a "time to build up" to generated forces. I have read, in reality a tire can take 250ms to really produce the max force it can bring. But i'm afraid it will do counterbraking and such things totally impossible to handle. [/list] Extreme measure i might try if results are not good enough in a few days :[list] [*]Directly rotating velocity vector of the car in some situations (i have to define situation+angle, help can be brought by KJM as it seems he is doing it in his game) [*]Limitating max torque / angAcc / angVel of the car [*]Artificially prevent car spins (eg: if rear wheels go to 55% of lateral force + the car has some important yaw velocity, introduce some mechanism that would stabilize it) [*]Limit weight transfer to a VERY small ratio [*]Use a linear pacejka curve [/list] I guess i'll have to implement proper springs/suspensions, but at this point i am not even close to measure the impact it would have on my simulation (good/bad, or more probably good, but not enough to make the game fun). I'm very interested by your experience and future answers [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  9. Hi again Thank you for sharing your experience with me (and other readers if any). [quote]But specifically for my game, i just rotate the cars velocity vector by the lateral Pacejka[/quote] Mmm, i have some trouble to picture that... You rotate car world velocity vector, from an angle you determine with the normalized lateral force ? Like 1 output = 1 radian rotation for velocity vector ? I'll try that kind of stuff to see the results ! EDIT : i missed this precious piece of knowledge : [quote]I noticed in your second video that your car reaches a maximum slip angle before it loses grip and spins around. This is classic of a Pacejka curve that peaks at a small slip angle. once past this peak, the tire has no grip and the car spins around. Altering your Pacejka curve so it looks similar to mine above should help prevent this and allow for drifting.[/quote] Thanks ! I'll try that right away [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [b]In your understanding, the controled drifting would occur after the peak (on the descending curve), or rather on the ascending part, before reaching the peak ?[/b] [quote]In theory, a physically accurate sim should be able to produce a wide range of handling for a car from an arcade drift feel to a simulation mode, by altering such things as the Pacejka curves, engine power, gear ratio's ect[/quote] That's what i think too, but it takes indeed quite a long time. The idea is to create a game that allows you to choose from a large variety of parts and even vehicule types. So having a nice basic simulation seemed a good idea. It still is, but we also need to have results as fast as possible. The game will be long term (web-based), so we will continue to investigate and work on the simulation until it produce satisfying result Ultimately we will want a large variety of game modes so having a rich simulation will also help to achieve that goal. [quote]For my Autocross Racing game i used lateral Pacejka coeficients similar to this curve.[/quote] I remember ploting one of my curves on this one recently [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I even re-used your pacejka formula from your demo source, but the result differ for the last part even when all previous results were the same as yours, i haven't really looked into this issue, so right now i use some simple dots. Oh and the 1164N output force (peak) for a small 1N load input confused me too. But i still can inspire of the general shape. --- So i guess from now on, i'll try to homebrew some sort of hack to make the game fun, as we would like to release a test version tomorrow. On the long-term, i think i'll have to find for myself what kind of feature is too violent, what is the acceptable range of effect of weight transfer, wheel slip, etc, and to find some physically not-wrong ways to stabilize the whole thing. I guess that realistic traction circle, with fine pacejka and 4 wheels weight transfer can produce an interesting result, only if the impact of each system does not exceed a few %. The ultimate goal is to be able to set any type of parameters and still be able to drive the car. We would like a game where players are able to change everything in the car. So we sort of rely on physics for the itemisation of car parts, as we'd like it to be random instead of predefined stages or prebuilt cars. So you could remove a truck tire to put it on a race car if you want, but the game has to produce something that provides both a physically logical effect and fun driving. I guess we still have a very long way to go,then ! [quote]If your priorities are to get an arcade game written as quickly as possible then i see no reason in hacking together an arcade sim, which is exactly what i did for my game.[/quote] Well, i will go that way for now, thanks for the advice, it is well appreciated, and as i said i willl then try to stabilize the basics of the car physics to support a more wide range of configuration in the future. [quote]You could use a third party car physics engine and i know some general purpose physics engines support wheel physics and suspension constraints (Newton physics engine for example) , so that may be an easier route for you.[/quote] Well the game will be full HTML5, so we can look at other libraries, but nothing exists out of the box. That's why we work so hard on this, it is like a challenge ! Maybe i'll buy [url="http://www.edy.es/dev/vehicle-physics/live-demo/"]this one in Unity[/url], and look at the source code to see what i can use. When i [url="http://www.edy.es/dev/2011/12/facts-and-myths-on-the-pacejka-curves/"]read this article[/url], it makes me want to ask a lot of questions to that guy ^^ The demo is quite convincing to me, with both realistic/arcade cars. --- Thank you so much to both of you for your time and helping me, and if it is not too much asking, (and your interest / work on the subject continues), i'd like to keep you informed of what i do next in the thread. Let's try to get something fun !
  10. Hi again ! Thank you so much for your detailed answers. I reinvestigated and rechecked every thing you said to me since the beginning, and each time i gain confidence on the fact i'm going the right way, so thanks again. It is very good to be able to say "now i dont have a doubt on the way i do this, anymore, so lets move on" [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] @bmarci Thanks for explaining so clearly. I tried your method over mine (i calculate force/torque for each wheel right away rather than summing), but as expected it gives me the exacts same results. So i guess my calculations must be good there. [quote]I would argue with that. In your post #6, the blue arrow IS the real velocity of the tyre, which is perpendicular to the vector from CG to wheel pos, but not to the wheel's heading. So it WILL generate both long/lat forces.[/quote] I agree, but i deactivated slip ratio, wheel angular vels around axle and any braking/acceleration force to simplify my steering behaviour research. I just apply 1*weightLoadOfCar/4 to the powered wheels for the moment. So in my case it will be only lateral forces generated right ? @both Thank you for explaining your way of using traction circle. I personnaly was ploting my curves for a normal load, applying traction circle (by croping excedent force) and then multiply by the load. The final result should be the same, but anyway i deactivated this feature right now. I think i really need your expertise to help me search the right way, because all the maths and physics we reviewed together seems ok everywhere. I have rewritten and triple checked all physics / maths functions. I "hope" i am wrong on this, but everything really seems ok there. So i would say the problem relies more on the car handling side of the problem. I have tweaked a LOT of parameters recently, and i can offen "sense" the same defaults in almost every configuration i tried. My general feelings are :[list] [*]Car seems way too much sensitive, or the total opposite. Controled drift are impossible due to very fast changes in car orientation [*]Car seems to acquire way too much angular velocity, too fast [*]Each time a wheeltrain acquires some force it will happily make my car oversteer/understeer dramatically fast [*]Quite offen, if i go fast enough and start to oversteer in a long controled slide, small changes (gaz/brakes/steer), will cause the car to violently change heading to realign with velocity trajectory (almost instant), or to realign with previous oversteer heading. [*]Car will easily spin, and then continue to travel backward [*]Applying full lateral vector to front wheels when steer angle is near 30° will result in extreme car slowing [*]If i have 5% more lateral traction in front wheels, the car will spin almost everytime ! [*]Dividing torque by 2 or 3 makes it better but still not perfect [*]It is almost impossible to have the car at 30°, sliding laterraly and to control the slide movement by changing acceleration or steering. Again, things seems to happen too fast [*]Very important thing i think is that the car will rarely slide laterally for a long time, as there is alway a force (front or back) that is higher and will make the car to align with direction vector one way or the other very fast [*]Car is not unstable or jittering, i test all kind of situations, and the response it gave me seems always appropriate, only way too violent / not enough controlable [/list] Those results are with :[list] [*]No traction circle [*]No weight transfer [*]1ms time step, which is small enough AFAIK [*]Deactivated wheel angular velocity, slip ratio and engine (only dumb front force when i press forward) [*]Drag/Air resistances (constants multiplied by worldVel or worldVel² to have some damping), very negligeable [*]Regrouped wheels to middle of car (no X), as it changes almost nothing in behaviour, to avoid eventual calculation errors [*]Car mass : 1500Kg [*]Car Weight / Tire : 3700 [*]Car inertia : 700 [*]Car CG is centered, front wheels are 2m front and back wheels 2m back [*]Car total length is 4m [*]Pacejka lateral curve is like this : [/list] [CODE] this.slipAngle = [0, 1.0, 3.0, 5.0, 9.0, 11.0, 20.0, 30, 40, 50, 60, 90]; this.lateralForce = [0, 0.7, 0.9, 1.0, 1.1, 1.15, 1.20, 1.15, 1.1, 1.0, 0.9, 0.80]; [/CODE] When i compare this to your racing game K_J_M, (first i am telling me that it is a very nice game you have made ^^), and then the first car available in demo seems to gain some +/- angle easily, then it slides a little to prevent lateral motion, and it seems really soft and smooth. I can use all parameters i want, i still not have succeed to have this kind of nice feeling. My point of comparison are recent casual games (like death rally), the KJM racing game, my game when i use non-realistic physics to try to have a nice behaviour, and ultimately games like GT, Grid or NFS series. So from most arcadish to most realistic, i still miss a big something to make my car controlable as those games do. For your implementations, as soon as you had lateral pacejka and base the base physics right, did you managed to create a fun, controllable car right away ? Or did it recquire some more hacks/forces downscaling or real physics features stuff (like front slip ratios) to allow for controled drifting ? For example the small demo you shared on the "car headache" thread started by marci, if i remember correctly, you apply angular velocity right away as we press left/right. And you scale the lateral pacejka to front speed, too ? Is it because the demo is simple, or is it because it just works better that way ? I'm shooting a video or two to try to illustrate the fact the car behaves quite good until it spins, and the "trajectory auto-realign" stuff i was talking about. I look at my samples again and again, but my intuition gives me nothing on this, i feel like i have the basics right and i have tried changing almost every value i have here and here without enjoyable results... [b]Video 1 : [/b]You can see in the second curve the weird alignment thing i was talking about. Front / Rear lateral forces are the same. Interesting values on the chart. Last run in slow motion. The lateral force is simply slipAngleInRads * 1 * weightLoad All others parameters are as i have explained above. http://www.youtube.com/watch?v=1rbELUuJUAY Except for that, i can have some controlled drift with a linear slipAngleInRad * someConstant force output. [b]Video 2 :[/b] An oversteer manoeuver with the pacejka curve i posted just above. The front lateral force is 5% higher (multiplied by 1.05). Along the video i am varying various parameters (lateral output magnitude, trying to accelerate in cornering to help, setting front/rear lateral force to equal, or back lateral to 95% of front). It demonstrates that very few parameters variation can cause very fast spin vs. successful cornering. No controlable drift with those parameters... http://www.youtube.com/watch?v=g2kfy5qTBxo
  11. Hi, That's bad for me because i get much better results applying the lateral force directly to car chassis regardless of steering angle (but i take it in count for slip angle calculation). Maybe i just need to tune pacejka curve to respond to the fact it changes the car behaviour somehow. A little change alway seems dramatic in result at first, but maybe it is the right way to go and i need to adapt my curves which are really trivials for now. [quote]Although i'm no expert, i always understood that a stationary car spinning on the spot with the steering centred produces no longtitude forces from the tires to move the car forwards or backwards. But only lateral forces to slow down the rate of spin.[/quote] As i understand it, when wheels are centered, the lateral response will be perpendicular to wheels, and will then slow down car rotation, but it will not introduce longitudinal force. The longitudinal force component present on the wheel during spinning will just introduce a diffrent slip angle result. I re-checked marcos page for the steering section. He claims, after determining lateral force using pacejka curve, that they have to be applied to the car body. He will apply both lateral forces directly to car body, and then use them separatly to calculate torque and finally introduce some yaw. Fine for me, but what does he have to say about the lateral component of the front wheels ? This : [quote]The lateral forces of the four tyres have two results: a net cornering force and a torque around the yaw axis. The cornering force is the force on the CG at a right angle to the car orientation and serves as the centripetal force which is required to describe a circular path. The contribution of the rear wheels to the cornering force is the same as the lateral force. For the front wheels, multiply the lateral force with cos(delta) to allow for the steering angle.[/quote] [CODE] Fcornering = Flat, rear + cos(delta) * Flat, front [/CODE] I'm quite rusted with my trigonometry, so i'm not 100% sure, but i think that will act as if the lateral response IS indeed perpenducular the the wheel, according to steer angle, BUT that he is suggesting to take only the force component that is projected on the car side axis. So if the front wheels are centered, 100% of the force will be applied. But if the wheel is steering at 60°, only 50% of the force is applied to the car. But he is only calculating centripetal force and torque, so i guess only the truly lateral component does it. He may have "forget" the sin(dela)*Flat, front which is supposed to slow down the car as it is cornering, but maybe it is not that important for the car behaviour ? If i release the gaz pedal, it may slow down the car by a similar amount. If i'm right, that would mean, that i just should try to have better steerAngle/steerSpeed/lateralCurves constants instead of looking at the maths. --- One other question as i'm experimenting if i may : Do you know if traction circle should be applied before or after taking count of weight load ? Because when i slow down the car in/before curves, so much weight get transfered to the front that the lateral force increase happens way too fast and the car can make an half-turn really easily. I feel like traction circle should be capped at some maximum load or maybe my weight transfer needs a real spring instead of a simplistic time integration of the weight transfer. By the way, it feels a bit strange to me that only weight transfer due to +/- acceleration affects cornering capacity in curves. Am i missing something here or again, should i just tune weight transfer speed to get something smoother to drive ? [b]EDIT [/b]: after re-reading closely PHORS articles, it seems only acceleration/weight transfer affects available traction and it is supposed to scale linearly with weight load, indefinitely. http://phors.locost7.info/phors07.htm --- Thanks for your help and sharing your experience ! You say you are not expert, but given the quality of your racing game, i'll take your advices very seriously ! It's exactly the kind of feeling i want, only more arcade-ish.
  12. Oh, and i have one more question that has haunted me those past days. Knowing that marcos slipAngle formula is made to be used with car coordinates (that's why it takes angular vel, and so) to determine the lateral force the tire produce, it makes sense that this lateral force should be applied to the car directly perpendicular at wheel position. But, i use a formula where the front/lat velocities are the real ones of the wheel. So, simply using this formula should work to determine slip angle : [CODE] var alpha = -Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity)); [/CODE] But when it comes to applying that lateral force... Case 1 : Should i apply the given force perpendicular to wheel, with steering producing an oriented lateral force, which will slow down the car ? Case 2 : Or instead should i apply it perpencular to wheel attach point, regardless of steering, and then it will only make the car turn, but never slow it down ? Case 1 example : [img]http://img546.imageshack.us/img546/1576/lateralforceappliedonti.jpg[/img] Case 2 example : [img]http://img267.imageshack.us/img267/1834/lateralforceappliedonbo.jpg[/img] Everyone use its own formula and coordinate system in the examples i have found, so it is not clear to me. For Slip Ratio, it is more obvious as we look at patch speed (wheel angular velocity) and ground speed in the direction the wheel is heading, it seems logical to have that vector acting in the wheel space, thus respecting steering angle. But using a simplified formula with examples were it is used to apply a force directly perpendicular to car makes me have some doubts...
  13. Hello to both of you ! Thanks for your detailed answers. As always, i really appreciate it. I worked very hard those past days on the simulation, and made some progress. @K_J_M & @bmarci [quote]If you look at the issue with regards to local car coordinates then each wheel has 0 longtitude velocity and (N) Lateral velocity if the car is spinning on the spot.[/quote] That is right, but when i look at a point in a system, i use my pointVelocity method which takes angVel in account like you said [quote]But in regards to a stationary car spinning on it's axis the lateral wheel velocity is derived from the car angular velocity.[/quote] So, theorically, when spinning on itself, any point velocity depends on angular velocity of the car. That velocity will be tangent to rotation circle and depends on distance to CG. The wikipedia page illustrates this very well : [url="http://upload.wikimedia.org/wikipedia/commons/2/2f/Velocity-acceleration.PNG"]http://upload.wikime...cceleration.PNG[/url] So i have something like that : [img]http://img837.imageshack.us/img837/6290/pointvelocity.jpg[/img] So, now, what bmarci said is exactly what i'm doing : [quote]1. Create transform functions between coordinate systems (World, Car, Wheel) and double check if they produce the wanted results. 2. Calculate everything in its own coordinates, eg: wheel forces in wheel space, car forces in car space...etc 3. Forget about steering angle in slip angle/ratio calculations. If you have the right transform functions, that will take care of steering angles. 4. Check the result of the ATAN(lat/long), especialy when dividing by long=0!!! The result should be +-PI/2[/quote] That's exactly the way i do things. So that means, i am transforming the point velocity of the wheel (the blue vector on the picture) in wheel coordinates, which as we can see it on the picture will result in both lont/lat velocities, and so in a slip angle which is not 90° when the car is spinning on itself. So the conclusion is in contradiction with what KJM stated above, but i can't see what is failing in my reasonment. Am i right to not find 90° for a wheel which belongs to the right place on a car spinning on itself ? The point velocity seems good, so if i am supposed to get only lateral velocity, i need a sort of hack, or maybe stay in car coordinates instead of going into wheel system ? The thing is, i am almost sure i am right on this and that my slip angles are good, because the wheel produce good damping forces to annihilate car angular velocity when spinning on itself. If tires produce 90° slip angles when the car is spinning the car is slowing down of 99% and not 100%. If my slip angles are good, that would mean that my car problems during cornering lies somewhere else. As i said i have obtained a better result, but i am not sure if my base calculations in slip angles are OK. So i cannot really try to tune pacejka or other things like wheel velocity and weight transfer if the underlying system is not good. Actually the result i have is very close to the Java source example you can download on marco's website. It seems ok as i have deactivated everything else : weight transfer, decreasing pacejka curve, no more real engine/wheel transmission / rotation. I needed to have a clean working table, sort of. But when i try the car on my game track it is far from playable. If i use an always increasing, producing high cornering forces curve for lateral pacej, then the car turns very sharply, and i can have somme controled oversteer, but the car will eventually stop in the turning curve instead of keeping some speed. If i use a realistic pacejka curve, then the car is understeering at high speed, which is good, because i can do high speed turns in a comfortable way. But, if i want to produce oversteer and drift for a sharper curve, it just doesn't happen. So, what do you think ? Problem in base system calculation ? Pacejka curve tuning ? Maybe i should reactivate some critical feature or system ? I will try to cast a video of the car later to show try to show you, if interested. Thanks for your help, my game really needs it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Sorry for the long posts by the way... EDIT : the main thing here, might be this "the car will eventually stop in the turning curve instead of keeping some speed". I have the feeling that when i take a sharp turn, even if a great part of the initial velocity will be killed by the lateral forces, and even without pushing throttle, the car should keep more front velocity to come out of the curve. Instead it just stops there with very small to none forward velocity. If i could have this, and manage somehow to mix the best of the 2 results i have with my different pacejka, the game would start to be fun i think. EDIT2 : those results were obtained with a dummy traction circle (allowing 2*weightLoad traction max), applied only on lateral force for testing purpose.
  14. Hi, K_J_M ! Thank you for your answer ! I already downloaded your top down racing game, but haven't had many time to play it yet ! It seemed a little hard to me at first sight [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] If i understand you, then a static but spinning car would generate velocities for tires that would be with 0 longitude, and some value in x depending on the direction of rotation. Something like that : [url="http://en.wikipedia.org/wiki/Uniform_circular_motion"]http://en.wikipedia....circular_motion[/url] I found it to be true if the tire is aligned with the radius of the circle. As the wheels are not centered, but rather on the side of the car, when they are not steering, then the radius from wheel attach point to car CG will not be perpendicular to the wheel heading. If you draw a path following the front right wheel positions, it is indeed a perfect circle, and the velocity of that point (blue vector) is indeed tangent to circle. But as my wheel is not aligned with the radius, the projection of the velocity according to steering (wich is 0), will give me both lateral and frontal velocities, wich in turn will give me a slip angle not equal to +/- 90°. The only case i have such results is if : a) There is only 1 front wheel, centered on the chassis (like a bike, or tricycle) b) The wheel is aligned with the radius coming from CG c) The car is sliding lateraly [img]http://img834.imageshack.us/img834/8581/circulatpath.jpg[/img] That is a little confusing to me, so i am wondering if :[list=1] [*]I should have 0 longitidunal velocities as long as the tire is describing a circular path, regardless of wheel steering. The steering would then be "used" in slip angle calculation like the formula from marco suggest it : [CODE] slip = Atan(latVel / |frontVel|) - signOf(frontVel) * steerAngle [/CODE] [*]I should have a longitudinal & lateral velocities (excepted for previous a,b,c cases) and my calculations are OK until there (the wheel front/lat velocities are the green and red vectors on the picture). [/list] I am suspecting it is not the only thing that goes wrong with my simulation but it would really helped me to know which way is the right one [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] And again, thanks for your help, it is much appreciated !
  15. Hi to everyone ! Another topic on car simulation, guys ! First i must say thank you to all previous car question posters and the great people who helped them (like Kunos, K_J_M, and many others...). You are my heroes since i started to work on my racing game a few month ago ! I have to say i have read and recoded every single tutorial available on the internet and studied a LOT of car physics game source codes, including the ones posted here. So, i'm developing this top-down racing game with semi-realistic physics where the main aspects are : having fun, nice skidding turns, and car parts looting/upgrading. So i need a credible model, not too realistic. Something with engine, torque curves, slip ratios, slip angles, a little of pacejka and newton physics seems perfect ! Everything is quite OK to me except the turning part, which is always tricky. I spent the whole week on this topic : [url="http://www.gamedev.net/topic/630058-vehicle-simulation-headache/"]http://www.gamedev.n...ation-headache/[/url] and it helped me as much as it confused me ! Before explaining my problem in details and start asking what i may be doing wrong, i think the best is to ask for some clarifications about a thing or two that still confuse me (like conventions, and so). So, my [b]first question[/b] will be about the tires longitudinal and lateral velocities used in the formulaes. It is the basing element everyone talks about and no one ever takes time to explain seriously. Here are my assumptions about how to get those lat/long velocities :[list=1] [*]Start with the car local velocity [*]Get world velocity of the car [*]Get the world coordinates of the wheel you want to calculate things for [*]Get the world velocity of this point (ie : the speed at wich the ground flies beneath that point) THAT MEANS : if the car is not moving, but is spinning on itself, there IS a velocity for each tire in X/Y. I am precising this because this assumption of KJM confuse me : [quote]If we assume your car is stationary and points at 12 o clock with the front wheels centred, but is spinning on it's axis (yaw) then the wheels generate 0 slip angle because there is no long or lat linear velocities of the car.[/quote] [*]Convert the point velocity in car frame if necessary. [*]FInd unit vector in front/side of the wheel, and rotate them according to steer angle of the wheels. [*]The previous point velocity vector is projected on unit vectors to find front/side velocity. [*]As i can't use the Length() method of my vector (which returns unsigned result), let say i rotate back the projected vectors of -steerAngle, so i can have the length directly with the x/y values. [*]The X value of the projected vector on side is the lateral velocity (signed), same goes for the longit velocity with Y. [*]Positive X means the wheel is moving to the right. [*]Positive Y means the wheel is moving to the front. [*]In order to be a side friction, the slipAngle must always be of the opposite sign of the lateral velocity of the wheel (after all the perpendical friction of the wheel does nothing besides slowing an already existing velocity, which in returns generate a cornering force allowing us to turn the car). Am i right ? [/list] A few examples to make sure i understand everything on this definition of frontal/lateral velocities : (friction is not enabled in examples so the car keep applying any force i gave initially) I will use the front right wheel as base for calculations of velocities in the examples. The formula i use to calculate slip angle is : [CODE] -Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity)); [/CODE] I guess this formula is wrong. I could use this one from marcos tutorial, but i am totally confused with the omega things, because i think my method already takes angular velocity and steer angle in count before that step... Anyway this formula is different of mine or the one you can see in [url="http://www.gamedev.net/topic/630058-vehicle-simulation-headache/"]this topic[/url]. KJM and bmarci even ended using slightly different formulas. [img]http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games_files/ct_alphas.gif[/img] [u][b]Example 1[/b][/u] : a car is heading front at 4m/s. The front wheels are steering at Pi/6 (30°). You can see a picture of it here with the different measured values and vectors as my simulation knows them : [img]http://img836.imageshack.us/img836/7931/forward4mpssteerright30.jpg[/img] I hope it is self-explanatory and explicity enough. You can see the values i found for the car X/Y velocity, the ones of the wheel after 30° steering and the associated slip angle (30°). I think everything is ok until there, but if not, please let me know. [b][u]Example 2[/u][/b] : now the car has no velocity but is spinning on itself. I made a video so it is easier for you to see what is happening i guess. [media]http://www.youtube.com/watch?v=UVDDYB-FDYI[/media] [u][b]Example 3 [/b][/u]: will be exactly the same thing as #2, but with the car being moving in a fixed direction AND spinning on itself. Remember, response forces are deactivated so the car is free to do crazy move. I'm just measuring values here. In first case, the car is not moving fast enough forward before i apply the angular velocity, so the main friction force is here to slow down the car yaw [media]http://www.youtube.com/watch?v=O3-zo8oxvik[/media] In the second case, the car has more velocity before starting to spin on itself, so the tire friction tries more to slow down the car. The lateral response vector (the great black vector coming out of the screen) change side accordingly to the car orientation and direction of travel. [media]http://www.youtube.com/watch?v=uiwiwxA4g5o[/media] I noticed the black response vector sometimes switch side too late, when it reaches 6 o clock. It may be important or not, but i am sure to use the right tire coordinates, so may be more important as it seems ? ---- The examples i posted here seems to be OK to me, but when i try to apply the calculated forces, the car implodes because of too high constraints (sort of). It doesn't work. Actually, depending on initial heading of car, things happens differently... Which is odd and reminds me of the very first hour of my simulation when nothing was stable and was doing very silly vector/angle/physics engine miscalculations. For example, i use box2d which does not have the same coordinate system as my sim, it can sometimes be confusing. Before going further into the problem and the questions i may have, i was wondering if someone could have a look and says if something seems really wrong or if it seems ok until there. Any help will be much appreciated ! Thanks !!! Raphael