ShayF2 Posted November 17, 2018 Share Posted November 17, 2018 I want to add to a value per frame, for some reason it sticks to a single value, the speed value, instead of the actual value its self. -- Serverside creates data and syncs with clientside via element data. Tbh serverside isn't needed at all. self.wx1, self.wx2 = getDefaultWheelSize(self.vehicle) for i=1, self.wheelAmount do self.wheels[i] = { wheel = createObject(self.model, 0, 0, 0), width = 0, cam = { camber = 20, -- what you want it to be, this is whatever you set camber to current = 0,-- this what it currently is in-between gradual movements increment = 0.97, speed = 2, onGround = isVehicleOnGround(self.vehicle) } } iprint(self.wheels[i]) if i == 1 or i == 2 then setObjectScale(self.wheels[i].wheel, self.wx1) else setObjectScale(self.wheels[i].wheel, self.wx2) end end -- clientside, where all the :~ is done. for i=1, #self.wheels do if isElement(self.wheels[i].wheel) then dxSetShaderValue(wheelShader, 'red', 0.25) dxSetShaderValue(wheelShader, 'green', 0.25) dxSetShaderValue(wheelShader, 'blue', 0.25) dxSetShaderValue(wheelShader, 'alpha', 0.25) engineApplyShaderToWorldTexture(wheelShader, '*', self.wheels[i].wheel) local x, y, z = getVehicleComponentPosition(self.vehicle, wheelNames[i], 'world') local rx, ry, rz = getVehicleComponentRotation(self.vehicle, wheelNames[i], 'world') local sx, sy, sz = getObjectScale(self.wheels[i].wheel) local newPos1 = (z-(self.wx1/2))+(sy/2) local newPos2 = (z-(self.wx2/2))+(sy/2) local camber = self.wheels[i].cam if isVehicleWheelOnGround(self.vehicle, i-1) then if camber.current < camber.camber then if camber.current > camber.camber then camber.current = camber.camber else end end else --if camber.current > 2 then --if camber.current < 2 then camber.current = 1 end --camber.current = camber.current - (camber.speed * camber.increment) --end end if i == 1 or i == 2 then setElementPosition(self.wheels[i].wheel, x, y, newPos1) else setElementPosition(self.wheels[i].wheel, x, y, newPos2) end setElementRotation(self.wheels[i].wheel, rx, ry-camber.current, rz, 'ZYX') end end So I want camber to be smooth, when vehicle isn't on the ground then the wheels are straight, but as it comes back to the ground, gradually go back into camber state. Basically adding a realistic effect to the wheels. The camber is stuck at the speed value created on server side. Tbh, good luck with this one. Using a better version of interpolate. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now