Yue Posted July 21, 2018 Share Posted July 21, 2018 I want to implement wheel steering, however my attempts are unsuccessful, as I have put two additional pivots on the springs on the front tires, and created hinge joints but blocked the movement of the tires when moving the vehicle. Any suggestions are welcome. Script.rueda = nil --entity "Rueda" --Wheels Script.chassis = nil --entity "Chassis" -- Chassis function Script:Start() MotorVehiculo(self) end local vel = 0 function Script:UpdateWorld() self.Motor:DisableMotor() if window:KeyDown(Key.W) then --if tostring(self.entity:GetKeyValue("name")) == "Susp2" then self.Motor:EnableMotor() self.Motor:SetAngle( self.Motor:GetAngle() - 100 ) -- end if vel <=500 then vel = vel + 10 end end if window:KeyDown(Key.S) then self.Motor:EnableMotor() self.Motor:SetAngle( self.Motor:GetAngle() + 100 ) if vel <=500 then vel = vel + 10 end end if window:KeyDown(Key.Space ) then self.Motor:EnableMotor() vel = 0 end self.Motor:SetMotorSpeed( vel ) if window:KeyHit(Key.J) then self.chassis:AddForce( 0, 5000*3, 0 ) end end function MotorVehiculo(self) self.posAmortiguador = self.entity:GetPosition() --Spring self.Amortiguador = Joint:Slider(self.posAmortiguador.x, self.posAmortiguador.y, self.posAmortiguador.z, 0,1,0, self.entity, self.chassis) --self.Amortiguador:SetSpring(200 ) self.Amortiguador:EnableLimits() self.Amortiguador:SetLimits( 0, 0.01) self.Amortiguador:EnableMotor() self.Amortiguador:SetTargetAngle(0) --Hinge / Motor Wheels self.posMotor = self.rueda:GetPosition() self.Motor = Joint:Hinge( self.posMotor.x, self.posMotor.y, self.posMotor.z, 0, 0, 1, self.rueda, self.entity ) self.Motor:DisableLimits() self.rueda:SetPickMode( 0 ) self.entity:SetPickMode( 0 ) self.rueda:SetFriction(1, 1 ) end Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted July 22, 2018 Solution Share Posted July 22, 2018 It will work. The wheels with steering need an additional pivot between the suspension pivot and the wheel. This pivot uses a hinge joint with an axis of (0,1,0). The motor for this joint should be enabled at all times, and you just set the target angle to control the steering. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Yue Posted July 23, 2018 Author Share Posted July 23, 2018 19 hours ago, Josh said: It will work. The wheels with steering need an additional pivot between the suspension pivot and the wheel. This pivot uses a hinge joint with an axis of (0,1,0). The motor for this joint should be enabled at all times, and you just set the target angle to control the steering. ok? Quote Link to comment Share on other sites More sharing options...
Yue Posted July 24, 2018 Author Share Posted July 24, 2018 This continues without working, in which case, the steering axle ("pivot") is the one that moves and not the rim. I welcome any suggestions. Script.rueda = nil --entity "Rueda" --<<< Wheel Dir -- This script atach pivot dir. function Script:Start() self.volante = self.rueda:GetPosition() self.dir = Joint:Hinge( self.volante.x, self.volante.y, self.volante.z, 0, 1, 0, self.entity, self.rueda ) self.dir:DisableLimits() end function Script:UpdateWorld() self.dir:SetAngle( self.dir:GetAngle() + 100 ) self.dir:EnableMotor() self.dir:SetMotorSpeed(1000) end Quote Link to comment Share on other sites More sharing options...
Yue Posted July 24, 2018 Author Share Posted July 24, 2018 It is now possible to turn the rim, but it does not roll with the engine drive. Script.rueda = nil --entity "Rueda" -- Wheel Script.susp = nil --entity "Susp" -- Spring function Script:Start() self.volante = self.entity:GetPosition() self.dir = Joint:Hinge( self.volante.x, self.volante.y, self.volante.z, 0, 1, 0, self.susp, self.rueda ) self.dir:DisableLimits() --self.dir:SetLimits(-35, 35 ) end function Script:UpdateWorld() self.dir:SetAngle( self.dir:GetAngle() + 100 ) self.dir:EnableMotor() self.dir:SetMotorSpeed(10) end Quote Link to comment Share on other sites More sharing options...
Yue Posted July 26, 2018 Author Share Posted July 26, 2018 The following diagram shows how I have implemented the chassis, and the movement of the tire but I have no idea how to put in an additional pivot for the steering. sdf Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.