Mocking up a apocalyptic level for a game i am creating .. sort of a dayz game atm. first screenieView attachment 294602
if math.fabs(logic.car["speed"])<2.0: s = 1.5
else: s = 3.0 / logic.car["speed"]
##Gearbox##
gearList = [-3.417, 3.417, 1.950, 1.357, 1.054, 0.854]
final_gear = 3.939
gear_select = gearList [ logic.car["gear"] ]
##RPM calculation##
rpm = logic.car["speed"] / (0.1037 / (gear_select * final_gear))
##Torque calculation##
pt_rev = 5000
if gas == 1:
if rpm < pt_rev : torque = 10 + (rpm * 0.001)
else : torque = 15 - (rpm - pt_rev) * 0.002
else:
torque = rpm * -0.0005
##Power calculation##
if rpm > 7500 :
power = 0
elif speed < 10 :
power = 21.7
else:
power = rpm * torque * 0.001485
I like the Porsche Center
Here's a sound check for my turn indicators.
Sound check 2:
Update: New physics model! With the old model, steering was the same no matter the speed of the car. With this new code, steering is relative to the speed:
Code:if math.fabs(logic.car["speed"])<2.0: s = 1.5 else: s = 3.0 / logic.car["speed"]
If speed is less than 2.0, steering will be 1.5. Else steering will be 3.0 / speed.
The formula may need to be tweaked to give a somewhat realistic feel, but it's a good start.
Another update: I think I may have a solution for making an engine and a gearbox. I've got it figured out on paper (the coding is still work in progress):
Code:##Gearbox## gearList = [-3.417, 3.417, 1.950, 1.357, 1.054, 0.854] final_gear = 3.939 gear_select = logic.car["gear"] ##RPM calculation## rpm = logic.car["speed"] / (0.1037 / (gearList[gear_select] * final_gear)) ##Torque calculation## pt_rev = 5000 if rpm < pt_rev : torque = 10 + (rpm * 0.001) else : torque = 15 - (rpm - pt_rev) * 0.002 ##Power calculation## if rpm > 7500 : power = 0 elseif speed < 10 : power = 21.7 else: power = rpm * torque * 0.001485
And I think I know how to implement engine braking: negative torque
Awesome work sir.
Careful though... this is GTP you physics will be wrong, and hundreds of threads will spawn to kill your creative mojo.
Well, as long as they haven't payed for anything I think the amount of rage will be tolerable
Just tested my powertrain code in a code simulator, and it works!
View attachment 295093
Update: This is getting less and less 3D and more and more programming, but I've just figured out how to make analogue accelerator and brake pedals
I wonder if my DFGT is compatible with Blender... probably not.
This needs it's own thread, it's definitely interesting enough!Well, as long as they haven't payed for anything I think the amount of rage will be tolerable
Just tested my powertrain code in a code simulator, and it works!
View attachment 295093
Update: This is getting less and less 3D and more and more programming, but I've just figured out how to make analogue accelerator and brake pedals
I wonder if my DFGT is compatible with Blender... probably not.
This needs it's own thread, it's definitely interesting enough!
If you need sounds buddy i have a few here, from supra's to fiesta xr2's pick your poison
A Peugeot 205 would be awesome Much better than the sound of me rubbing my hands
Here's a new video. I tweaked the variables to try and make the physics more realistic. Top speed is now just above 200 km/h.
And here it is with the Peugeot body.
Update: Ha! I just got oversteer I came off the accelerator and turned at high speed and got into a little slide. When I got back on the accelerator it got out of the slide.
Update 2: Everything is working as intended. Except for when the speed is negative, i.e. the car goes reverse. For some reason it make the rpm number a complex number, which can't be compared to floating numbers. So it looks like I'll have to come up with some exception scripts for when the speed is negative.
Update 3: Instead of making exceptions scripts for every single calculation I just told the computer that if it thinks that the speed is less than 0 then it's actually wrong and the "true" speed is in fact 0. It solved the issue, but I imagine that it's going to be an obstacle when I want to add a reverse gear.
Update 4: Added a condition that makes gear changes undoable unless the clutch is at least 50% disengaged.
As promised i made a start the car appears in the game engine not bad for 2 hours work, had to mess around and make some normal maps and secular maps and fiddle with the shader's but she looks good. start rigging tomorrows
View attachment 296179 View attachment 296180
With the wheel code have you tried lowering the grip on the center so it's equal to the side walls. Should have 3 zones in your code at least for n's center o's zones per tyre . Or could be simply wheels are not making contact the road fully
The issue is that I don't see the tyre code, because it's part of the vehicle simulation which is built into the bullet physics engine and not part of the python code than I'm writing. I guess I could code my own vehicle simulation script, but that's going to take a while.
Speaking of tyre model, I made a new mesh for the tyres and wheels, 106 Rallye style
View attachment 296308
Yes, they are ten times more detailed than the rest of the car.
Yeah that could be a issue if you haven't got access to the tyre code. had to tweek the cat i didnt apply any shaders to body or engine. so now its ready to rig. what do you use to capture mate video mate?
edit: help if i added the picture
I think this was the project I used to get my TR4 in Unity, the car will turn quite sharply but that can be toned down easily enough, it's a modified version of a project that can be found in the asset store. Good job on the car it looks higher poly than the wireframe suggests.@Peasantslayer thanks mate, only taken few hours to get to this point project only started yesterday, so quite good progress only been using unity3d a month. just looked at your work it's amazing how long you been modeling
@eran0004 Thanks bro just downloaded it did u get small 4cyl sounds, before kaz hires you as a sound enginer
Just upload few clips
Here's the car with the Lupo sound. Sounds a bit like a cat, but it's better than the old sound
video is private lol were not worthy
@Peasantslayer i did try that the first day i had unity, didn't rate it much seemed like it was driving around a pivot on the rear bumper. but it was the 1st day so can always try it again since i know unity a little better not much better mind.
Edit: actually i think it may be a modified version of the demostration bundle but using the same track. i'll check it out
Oops. Well, here's a new and better video. I fixed some sound issues at the high and low revs. There's still an issue with too high sound level when the engine works at high rpm, I should turn down the volume multiplier.
By the way, what's your method of implementing sounds? Do you use different samples at different rpms?
@eran0004 Sounds good mate what sample did you use out of that pack? id use lupo_4_on seems as if you only have one sound for the engine and it's revving into the 9,000 - 10,000 range this might help with a deeper note, i have just 2 atm just engine start and basic mid pull.. i can have multiples but haven't found the correct mix yet volume wise it's really loud and quite distorted so have so mess around with that. seen as your in blender i couldn't say i only installed it then 10 mins later uninstalled it. looked a mess and made my screen flash.
On a positive note i present dynamic time
Amazing what you can do with unity