Yue Posted January 12, 2020 Share Posted January 12, 2020 I have a vehicle that is made up of several joints, sliders and hinges. I don't know how to turn the vehicle, i.e. by script, change its angle on its Y-axis, or change its initial position. If I try it like I really did with SetPosition, or SetRotation, I don't get the results I expected. That is, I can only mark its position and initial angle using the map editor, but I can't do it by script. Translated with www.DeepL.com/Translator (free version) TEMP 2020-01-11 19-36-16.mp4 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted January 12, 2020 Author Share Posted January 12, 2020 Here Script vehicle System. -- ********************************************************** -- Fichero Script : CVehicle.lua -- Notas : Fichero Clase para objeto / Vehiculo. -- Scripter : Yue Rexie. -- ********************************************************** -- Sitio Web : http://www.iris3dgames.ga -- Fecha : Viernes 10 de Enero / 2020 -- ********************************************************** vehicle = {} function vehicle:New(chassis,wheels,springs,axis) local this = {} function this:Start() this.chassis = chassis this.wheels = wheels this.springs = springs this.axis = axis this.axisFL = nil this.axisFR = nil this.springFL = nil this.springFR = nil this.springBL = nil this.springBR = nil this.hingeWFL = nil this.hingeWFR = nil this.hingeWBL = nil this.hingeWBR = nil end this:Start() function this:Init() self:InitSprings() self:InitMotorWheels() self:InitAxisW() end function this:InitAxisW() self.axisFL = self:CreateHinge(self.axis.FL, self.springs.FL,0,1,0) self.axisFR = self:CreateHinge(self.axis.FR, self.springs.FR,0,1,0) self.axisFL:EnableLimits() self.axisFR:EnableLimits() self.axisFL:SetLimits(0,0) self.axisFR:SetLimits(0,0) end function this:InitSprings() self.springFL = self:CreateSpring(self.springs.FL) self.springFR = self:CreateSpring(self.springs.FR) self.springBL = self:CreateSpring(self.springs.BL) self.springBR = self:CreateSpring(self.springs.BR) end function this:InitMotorWheels() self.hingeWFL = self:CreateHinge(self.wheels.FL,self.axis.FL, 1,0,0) self.hingeWFR = self:CreateHinge(self.wheels.FR,self.axis.FR, 1,0,0) self.hingeWBL = self:CreateHinge(self.wheels.BL,self.springs.BL,1,0,0) self.hingeWBR = self:CreateHinge(self.wheels.BR,self.springs.BR,1,0,0) end function this:Update() if Window:GetCurrent():KeyDown(Key.F) then self.chassis:AddForce(0,5000,0) end end -- Joints. function this:CreateHinge(child,parent,pinX, pinY, pinZ) local posChild = child:GetPosition(false) local h = Joint:Hinge(posChild.x, posChild.y, posChild.z, pinX, pinY, pinZ, child, parent) return h end function this:CreateSpring(spring) local posSpring = spring:GetPosition(false) local s = Joint:Slider(posSpring.x,posSpring.y,posSpring.z, 0,1,0,spring, self.chassis ) s:EnableLimits() s:SetLimits(-0.05,0.02) s:SetSpring(1,0.5,1) return s end return this Quote Link to comment Share on other sites More sharing options...
Josh Posted January 12, 2020 Share Posted January 12, 2020 Maybe you need to move the vehicle and all tires? 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...
Josh Posted January 12, 2020 Share Posted January 12, 2020 The new car looks a million times better, by the way. 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 January 12, 2020 Author Share Posted January 12, 2020 6 hours ago, Josh said: Maybe you need to move the vehicle and all tires? I have tried to move the tires and the whole vehicle, but the tires for example rotate relative to their local coordinate and not relative to the vehicle. 6 hours ago, Josh said: The new car looks a million times better, by the way. You always get better at something, over and over again practicing you always see something more beautiful. 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.