I really need to fix that bug.
David do you have a test that I can use to fix it for real?
It keep comming back and I want to know why it is happening and fix it.
Moderators: Sascha Willems, walaber
tork = powerPerWheel / ((2 * Pi) * wheelOmega)
PJani wrote:And for some reason when fps is high the breaks are working normal but when fps is low breaks just dont "grab" enough to make nice turn. As in the video at the end.
Aphex wrote:PJani wrote:And for some reason when fps is high the breaks are working normal but when fps is low breaks just dont "grab" enough to make nice turn. As in the video at the end.
Are you updating Newton with a fixed timestep?
Dave Gravel wrote:I use similar method here too, my joint is named tire projection and the vehicle is external to this joint.
http://www.youtube.com/user/EvadLevarg? ... p0fFOZH--U
Yes it's better for have more controls and more possible configuration, like tank...
You really need a math for calcul the good torque and update it with the same step use for update newton.
Different gear at different revolution, for get good effect you really need to use real setting for the simulation size.
Exemple you need real mass value or equiv, real mass center ..., real friction ..., real suspenssion ..., real tire mass ..., newton frame rate...
Exemple if the mass center is so low ex: -1 or more, You need more friction or the tire sliding easier.
If you use right mass center for your simulation size, You need to use very low friction because the tire have a lot more grip.
The best is to experiment a lot with it, many thing can make a difference.
The most important is that your value of anything stay on the ratio of your simulation size.
Dave Gravel wrote:If it's not already the case try to make a gear math system for calcul your torque for every frame dependent by a engine rpm.
-- [1] BEGIN 5 speeds engine simulation.
TEngine = class(TOXLuaClass)
function TEngine:Create(hp,mrpm,g1,g2,g3,g4,g5,g6)
self.hp = hp
self.maxrpm = mrpm
self.rpm = 0
self.curgear = 1
self.enginetorque = 0
self.automatic = true
self.diffratio = 3.6
self.geareffic = 0.7
self.accelerator = 0
self.revo = 0
self.revores = 0
self.gears = {g1,g2,g3,g4,g5,g6}
end
function TEngine:LookupTorque()
if (self.rpm < 7500) then
return 390
end
if (self.rpm < 8500) then
return 390*(1000 - (self.rpm - 7500))*0.001
else
return 0
end
end
function TEngine:GearShifter()
if self.automatic then
if (self.rpm >= 4000) and (self.curgear < 5) and (self.curgear>0) then
self.curgear = self.curgear + 1
end
if (self.rpm <= 2000) and (self.curgear > 1) then
self.curgear = self.curgear - 1
end
end
end
function TEngine:DoRpm(tireRad,v,speed)
local wrsp = (speed / tireRad)
self.rpm = (wrsp * 60 * self.gears[self.curgear] * self.diffratio / (2.0 * math.pi))
end
function TEngine:PushAccel()
self.accelerator = self.accelerator + 0.02
if self.accelerator > 1.0 then
self.accelerator = 1.0
end
end
function TEngine:LeaveAccel()
self.accelerator = self.accelerator - 0.01
if self.accelerator < 0 then
self.accelerator = 0
end
end
-- [1] END
function TVehicle:CervoEngine()
onAccel = false
gspeed = self:GetSpeed()
self.engine:DoRpm(tires[0].majorradius ,self,gspeed)
self.engine.revo = self.engine.accelerator
* self.engine:LookupTorque()
* self.engine.gears[self.engine.curgear]
* self.engine.diffratio
* self.engine.geareffic
if self.vtype == CAR4X2 then
if IsKeyDown(self.vkleft) then
if steer < self.maxsteerangle then steer = steer + self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if IsKeyDown(self.vkright) then
if steer > -self.maxsteerangle then steer = steer - self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if steer>0 then steer = steer -self.steerratio end
if steer<0 then steer = steer +self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
end
if IsKeyDown(self.vkaccel) then
self.engine:PushAccel()
self:PushTorque(1,self.engine.revo)
self:PushTorque(2,self.engine.revo)
onAccel = true
else
if IsKeyDown(self.vkdeccel) then
self.engine:PushAccel()
self:PushTorque(1,-self.engine.revo)
self:PushTorque(2,-self.engine.revo)
onAccel = true
end
end
end
if self.vtype == CAR2X4 then
if IsKeyDown(self.vkleft) then
if steer < self.maxsteerangle then steer = steer + self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if IsKeyDown(self.vkright) then
if steer > -self.maxsteerangle then steer = steer - self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if steer>0 then steer = steer -self.steerratio end
if steer<0 then steer = steer +self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
end
if IsKeyDown(self.vkaccel) then
self.engine:PushAccel()
self:PushTorque(0,self.engine.revo)
self:PushTorque(3,self.engine.revo)
onAccel = true
else
if IsKeyDown(self.vkdeccel) then
self.engine:PushAccel()
self:PushTorque(0,-self.engine.revo)
self:PushTorque(3,-self.engine.revo)
onAccel = true
end
end
end
if self.vtype == CAR4X4 then
if IsKeyDown(self.vkleft) then
if steer < self.maxsteerangle then steer = steer + self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if IsKeyDown(self.vkright) then
if steer > -self.maxsteerangle then steer = steer - self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
else
if steer>0 then steer = steer -self.steerratio end
if steer<0 then steer = steer +self.steerratio end
self.tireprojection[0]:SetSteerAngle(steer)
self.tireprojection[3]:SetSteerAngle(steer)
end
if IsKeyDown(self.vkaccel) then
self.engine:PushAccel()
self:PushTorque(0,self.engine.revo)
self:PushTorque(1,self.engine.revo)
self:PushTorque(2,self.engine.revo)
self:PushTorque(3,self.engine.revo)
onAccel = true
else
if IsKeyDown(self.vkdeccel) then
self.engine:PushAccel()
self:PushTorque(0,-self.engine.revo)
self:PushTorque(1,-self.engine.revo)
self:PushTorque(2,-self.engine.revo)
self:PushTorque(3,-self.engine.revo)
onAccel = true
end
end
end
if self.vtype == MONSTER then
end
if self.vtype == BIGRIGS then
end
if self.vtype == TRAILOR then
end
if self.vtype == TANK then
end
self.engine:LeaveAccel()
self.engine:GearShifter()
end
function TVehicle:PushTorque(id,val)
self.tireprojection[id]:SetTorque(val)
end
Exemple:
impreza = TVehicle("")
impreza:LoadFromFile("impreza.3ds")
impreza:AutoSleep(false)
impreza:Position(0,5,0)
impreza:MaterialCollision(0.05,0.4,0.3,0.3)
impreza:NewtonMass(1180)
impreza:CenterMass(0,-0.25,0)
impreza:InitEngine(CAR4X4, 4,1.25,0.9,0.7,0.975,-3)
impreza:InitNewton()
impreza:AddWheelSpring(1.4,-0.6,0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(1.4,-0.6,-0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(-1.35,-0.6,0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(-1.35,-0.6,-0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
Users browsing this forum: No registered users and 0 guests