# jujunosuke

Members

113

188 Neutral

• Rank
Member
1. ## Replay Physics

dancingmad, thank you for your feedback. Now that i know what to do, i just need to implement it on my project.   Thanks again.
2. ## Replay Physics

Sorry dude but i didn't came on gamedev physics forum to get someone who give me a link to a product. I am here because i want to solve a problem and think with my head.   Otherwise i would have post on Unity forum don't you think so ? Make sens ?   Sorry i don't want to sound rude.
3. ## Replay Physics

i think i got it. I kind of replied my own answer.     So, here is the formula to interpolate two values or two Vector3 //================================================================== // INTERPOLATE //================================================================== public float interpolate( float x1, float x2, float x3, float y1, float y3 ) { return ( (x2 - x1) * (y3 - y1) / (x3 - x1) ) + y1; } x1 is the timing of the keyframe1 x2 is the current timing x3 is the timing of the keyframe2   y1 is the recorded position of the keyframe1 y3 is the recorded position of the keyframe2   It will return y2 which is the interpolation of keyframe 1 and 2. The position will change with the current timing     So basically, the interpolation can be done properly even if the framerate is not a fixed framerate because the position can be calculated at any moment with the interpolation function.   Thats it, i hope it help.
4. ## Replay Physics

dacingmad, thank you very much for your feedback. Instead of trying to replicate and reproduce the physics in my replay, i think i will go with the keyframe system as you mentioned. It just looks to be so less pain..   I have more questions though, i hope you can help me to clear my mind.   If during the game, i record something like this :   0.0 ==> carPosition.x = 0; 1.0 ==> carPosition.x = 10; 2.0 ==> carPosition.x = 20;     Because my game has no fixed time step, the framerate is every-time different. So if during the replay my camera angle is different, with more objects displayed on screen, i will never be able to reproduce the action at the exact same timing i recorded them..   Instead of being 0.0, 1.0, and 2.0 seconds it will probably play 0.03, 1.023, 2.054 etc...   Does that mean that i need to calculate the position of my car related to these value ?   For example if at recorded time 1.0 my car position is 10, when replayed at 1.023 it should be : positionX = 20(next position) - 10(actualPosition) = 10 * 1.023(currentTime) = 10.23   Is that pseudo code correct ?   What i want to say is that even if the replay time is totally different from the actual recorded time, i should be able to "guess" the position of the car with mathematic. Am i correct ?   And the last question, how often would i have to record keyframes ? The more i record them the more accurate the replay will be right ?   Anyway, thank you very much, and i hope you can understand my English because i am not native speaker.. Best regards.
5. ## Replay Physics

Hi everyone,   I would like to get some advice on how to make a visually convincing replay for my racing game.   I am using PhysX for the physics simulation and i am pretty sure that everything is non-deterministic. I am not sure how to verify if my time step is fixed or not ?   My first attempt at recording replay was very hilarious, and a big fail to say the least...   I tried to record user input (only input change) so every time i want to start recording i have a variable called recordedTime. This variable is incremented with the time step like this. if (isRecording) { recordedTime += Time.timeStep; } Then i would record the user input like this void recordAction( float time, string actionName ) { actions.Add( time.ToString() + "_" + actionName ); } so for example recordAction( recordedTime, "accel_on" ); etc etc.   But of course failed to reproduce the action properly. So i decided to add some keyframes at key moments in order to repositionate the car in the good position direction velocity and everything.     So i have a function that record pretty much everything. Car position, orientation, rigidbody velocity, rigidbody angularvelocity, same for wheels, etc...   But even after adding the keyframe system, it just does not worked as expected.   The thing, is i don't know really the tweaking i need to do in order to reproduce the same action at the same time. Should i use Update ? FixedUpdate ? LateUpdate ? to record action ?   I just struggle to understand the most fundamental concept. If i record acceleration input at 1.20 second, how can i play it again later with a different camera angle that is going to affect my framerate and then play the action faster or slower than 1.20 ?     So, instead of trying to reproduce everything in a physical way, i was wondering if it would be a decent solution to record the car position and orientation keyframes only, and then play a kind of linear transition between each keyframes in order to reproduce visually the movement of my car. What would you think about this option ? Does some professional games use it ?   Any feedback or advices would be very appreciated. Thank you in advance.
6. ## [Car physics] Wheels / Tire Traction torque

I made a mistake its 350 Nm @ 3200 (BMW M3 E36) Still very powerful     The fact is i was used to play with wrong torque feedback (forget to multiply by gear ratio), so my torque feedback was insanely strong. And i made all the other car settings based on that setting.   So yesterday i tried to play a little bit with the "new" settings and by increasing the grip on the wheels, and tweaking the cylinder inertia formula, i get much more decent results now. Also my Tachometer RPM needle feel really smooth hehe.     Thank you for the link, i have some reading now. I am a little bit scared every time i have to add one more thing to my transmission model (which is quite complex already). Its just another chance to forget something and make a single mistake that will screw up all the calculation   But i consider this topic as answered! Thank you very much for your time dear kunos!
7. ## [Car physics] Wheels / Tire Traction torque

So, if 164 nm is not low at all, that mean that my above code is correct ? Strange, i might have a problem or something i forgot somewhere..   My engine produce around 450 Nm at 3600 rpm. I then divide the 450 Nm by the inertia of a cylinder and multiply it by the gearRatios So @3600 rpm i get angularAcceleration = (450 / cylinderInertia) * gearRatios; And that is how i got my angularAcceleration on the rearWheels.   Then   angularVelocity += angularAcceleration * Time.deltaTime;
8. ## [Car physics] Wheels / Tire Traction torque

Hum, i divided the traction torque by the gear ratio and now i got catastrophic results... So traction torque seems completely out.   In the first 3 gears, the needle keep bouncing on the rev limiter like i had 3000 hp. (Now my car is arround 280 hp RWD). I might be doing something wrong somewhere.   Just to recap, Rev engine ---> getForce ---> multiply by GearRatios ---> getTheWheelsSlip on the ground ---> slipRatio Calculations ---> GetTractionForce that make move the car forward. Then the TractionForce is multiplied by the Rear Wheels radius and divided by the gearRatios to get the traction Torque that will slow down my engine.   So, if i get 3000 Nm of force for a 1 wheel that mean 6000 Nm of force that make the car move forward. Then TractionTorque = 6000 * wheelRadius / gearRatios; So 6000 * 0.34 / (3.82 * 3.26)     (first gear + final drive ratio) = 2040 / (12.45) = 164 (its ridiculously low!!)   At first i though i made a mistake and tried to multiply by the gearRatio instead of dividing it, but it just reversed the problem.   If the above pseudo code is correct, that mean that my problem is somewhere else then..
9. ## [Car physics] Wheels / Tire Traction torque

Hi kunos, long time no see! Thank you for your very quick answer!   Oh, i see! Now that you told me that it looks very obvious! That is why my brake torque traction was so strong! (And very wrong because the brake force was the same for all gears...)   kunos, i just can't count how many times you saved me from the mess..   I will test and report (as i always do) but i am pretty sure that it will work on my problem is solved. Best Regards.
10. ## [Car physics] Wheels / Tire Traction torque

Hi everyone,   I am not sure how i should calculate the traction torque that act as a brake/resistance on the engine.   For example, the real wheels of my car spins, and lets say that each wheels return 3000 Nm of Force. I am pretty sure that to transform that force in torque i need to multiply the returned force by the wheel radius right ?     So, for a rear wheel drive car for example, the Traction Torque that act as a Brake on the engine would be 3000 Nm * wheel radius + 3000 Nm * wheel radius = traction torque of both rear wheels ? Right now, i am doing 6000 Nm * wheel radius.     I am a little bit confuse. At the moment, my car traction torque is very huge and my car acceleration feel quite slow. The car doesn't rev very well.   Any feedback would be greatly appreciated.   Best regards.
11. ## [Car Physics] Sharing work, ideas, formulas and car parameters

About suspension and weight transfer, i don't know if the solution i used can help any of you guys. It is just a simplification of the concept, but honestly, i got pretty decent result and my simulation got better. As kunos said, i use physX as my physics engine, with 5 rigid body connected with joints. Basically i calculate the spring compression based on the distance of center of my wheel to the distance of my spring attached to the body of the car. You can decide about the spring distance free height. I set mine to 0.36 meters. That mean, if the car body is 0 kg the spring should not be compressed and give you 0.36 meters. Then i just do some calculation of the distance. Vector3 of the center of the wheel, Vector3 of the joint position. I then make calculation to get a result between 0 and 1. 0 mean that the spring is stretched to the max and give 0 grip. (spring free height) 1 mean that the spring is compressed to the max and give 100 % of grip. once you made that, calculate the total force that your tire should provide and multiply it by the result of the spring compression. Works decently for me and was really simple to implement. But of course, this technique is valuable only if you use a 3d physics engine as mentioned. I don't know what kunos think about this way of doing though..

14. ## [Car Physics] - Angular Velocity / Angular Momentum

[quote] nope.. that is a locked differential or a "spool", a limited slip allow tyres to turn at different speeds but in a "limited" (doh ) way. A spool adds tons of understeer to the car because the rear tyres will oppose to any change in relative angular speeds trying to straight the car up. This understeer is usually transformed into "snap" oversteer as soon there is too much torque for the tyres to handle. The car will be really really hard to drive. [/quote] Excellent kunos ! Thank you for all these informative answers ! I guess i have all the answers i was looking for and its up to me from now [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] See you next time! Best regards.
15. ## [Car Physics] - Angular Velocity / Angular Momentum

Damn kunos you answer too fast [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [quote]static friction only applies at velocity = 0 , so forget about that [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] As for "drift", it took me about 13 years to come up with a global model that allows my physics implementer to do a "drift" car... it really is that hard [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img], and the more your model is complicated the harder it gets. [/quote] Reading this is as fascinating as discouraging.. hehe. [quote]again, do not underestimate the role of differential modeling.. drift needs limited slip differentials, an open diff won't drift, and a spool won't drift.[/quote] In my sim, the real wheels turn both at the exact same rate, so i guess i already have a LSD config.. Anyway, after that much experience in car simulation, it is so great that you share your experience kunos. Tyre modeling is just fascinating and extremely complicated at the same time.. Btw, this next question is not related to my post, but just for curiosity, what do you think about physics used in game like Gran Turismo 5 or Forza 4 ? The tire model on this game is far to be perfect and is of course really simple compared to any good PC simulation. BUT they have the quality to be correct simulation with correct car behaviour for LARGE audience public. I know that you try to reach a kind of ultimate car simulation but, did these large public sims influenced you in any way ? ***EDIT*** What i mean is, we can control the car for laptime or drift with a simple standard controller, see the replay and still see acceptable car behaviour right ? This have to be quite challenging...