Karuzo Posted May 26, 2017 Share Posted May 26, 2017 Suh dude, I have this strange problem with setting the rotation of the tires on a vehicle. I'm trying to adjust the camber of the tire but without any success so far. This is my current code: The camber variable is the position of a scrollbar. The variable frontcamber outputs the right rotation set but on the vehicle itself there is no visible change. local veh = getPedOccupiedVehicle(localPlayer) local frontRightTire = "wheel_rf_dummy" local frontLeftTire = "wheel_lf_dummy" local backRightTire = "wheel_rb_dummy" local backLeftTire = "wheel_lb_dummy" local mincamber = 0 local maxcamber = 30 if camber == 0 then setVehicleComponentRotation( veh, frontRightTire, 0, 0, mincamber ) setVehicleComponentRotation( veh, frontLeftTire, 0, 0, mincamber ) setVehicleComponentRotation( veh, backLeftTire, 0, 0, mincamber ) setVehicleComponentRotation( veh, backRightTire, 0, 0, mincamber ) elseif camber == 100 then setVehicleComponentRotation( veh, frontRightTire, 0, 0, maxcamber ) setVehicleComponentRotation( veh, frontLeftTire, 0, 0, maxcamber ) setVehicleComponentRotation( veh, backLeftTire, 0, 0, maxcamber ) setVehicleComponentRotation( veh, backRightTire, 0, 0, maxcamber ) elseif camber>0 and camber<100 then local acccamber = interpolateBetween(mincamber,0,0,maxcamber,0,0,camber/100,"Linear") setVehicleComponentRotation( veh, frontRightTire, 0, 0, acccamber, "world") setVehicleComponentRotation( veh, frontLeftTire, 0, 0, acccamber, "world") setVehicleComponentRotation( veh, backLeftTire, 0, 0, acccamber, "world") setVehicleComponentRotation( veh, backRightTire, 0, 0, acccamber, "world") local frontcamber = getVehicleComponentRotation(veh,frontLeftTire) outputChatBox(frontcamber) end 1 Link to comment
Moderators IIYAMA Posted May 26, 2017 Moderators Share Posted May 26, 2017 I wonder if you can rotate tires like that. Why don't you try it with: https://wiki.multitheftauto.com/wiki/SetAnalogControlState ? Since you are only rotating the Z as. Link to comment
Karuzo Posted May 26, 2017 Author Share Posted May 26, 2017 5 minutes ago, IIYAMA said: I wonder if you can rotate tires like that. Why don't you try it with: https://wiki.multitheftauto.com/wiki/SetAnalogControlState ? Since you are only rotating the Z as. I think you didn't get what i'm trying to do: I'm trying to adjust the camber not the steering of the car. I tried with X,Y and Z but nothing changed. I want negative camber on my car: Link to comment
3aGl3 Posted May 26, 2017 Share Posted May 26, 2017 I don't think you can rotate the wheels at all, because their rotation is engine controlled. Link to comment
Moderators IIYAMA Posted May 26, 2017 Moderators Share Posted May 26, 2017 How about you try to pre render it? > onClientPreRender < Maybe the GTA is re-adjusting the wheels every frame. Link to comment
Karuzo Posted May 26, 2017 Author Share Posted May 26, 2017 I already tried out onClientPreRender, but for some reason it just doesn't work. Guess rotating the wheels at all is not possible, but positionating them works for some reason. Link to comment
3aGl3 Posted May 26, 2017 Share Posted May 26, 2017 4 minutes ago, Karuzo said: I already tried out onClientPreRender, but for some reason it just doesn't work. Guess rotating the wheels at all is not possible, but positionating them works for some reason. As I said before, the wheels rotation is controlled by the engine, you can actually use getVehicleComponentRotation on the wheels to get the steering angle. Link to comment
pa3ck Posted May 26, 2017 Share Posted May 26, 2017 42 minutes ago, Karuzo said: I think you didn't get what i'm trying to do: I'm trying to adjust the camber not the steering of the car. I tried with X,Y and Z but nothing changed. I want negative camber on my car: Did you also check the handlings? There might be a handling option to change that angle. Link to comment
3aGl3 Posted May 26, 2017 Share Posted May 26, 2017 The fifth and 6th byte of the model flags actually change the camber of the wheels. Link to comment
Karuzo Posted May 26, 2017 Author Share Posted May 26, 2017 1 hour ago, 3aGl3 said: The fifth and 6th byte of the model flags actually change the camber of the wheels. I never understood that conversion from bytes to flags, can you explain that to me? Link to comment
3aGl3 Posted May 26, 2017 Share Posted May 26, 2017 Well, flags are sort of easy to understand the more you break them down. First of all you have to know how a computer handles numbers, in particular integers. So let me give you the super basic rundown... Let's for example take the number 1337 as a Base10 number, what we usually work with. Now in Base16, also called Hex it would be, 539. Why hex you may ask, well one hex digit has exactly 1 byte. That being said the number would be 0101 0011 1001 in Base2, also known as Binary. Why all this? Well flags are stored as integer numbers, however their data is hidden in their binary form. Each bit stands for something that can be toggled on or off, being 1 or 0 respectively. Now since each bit is a different number you can have all of them in a different state. Let's take this for example: 1 (0001) - is van 2 (0010) - is bus 4 (0100) - is low 8 (1000) - is big Given these values: 1 van 2 bus 3 "van bus" 4 low ... 15 "low big van bus" GTA expands on that, taking 8 bytes and making them into one number, resulting in a full int_32 integer number. 2 Link to comment
Karuzo Posted May 26, 2017 Author Share Posted May 26, 2017 Yeah, i understand that. What i don't understand is, how I get to this decimal value generated by a hexadecimal value. F.e.: 0x12345678 How would the number look like if i want to set the Flag "AXLE_F_MCPHERSON" ? Link to comment
3aGl3 Posted May 26, 2017 Share Posted May 26, 2017 As far as I understand it you simply set the desired bits on in the byte and build the hex number like this: 0x0004400 or 0x0044000 depending on what endianess the game uses for those flags. Link to comment
Slim Posted October 10, 2017 Share Posted October 10, 2017 (edited) https://wiki.multitheftauto.com/wiki/Vehicle_component_manipulation In our upcoming server update we're using this exact method. Hope that link helps, my Russian friend scripted it for us, took him a couple hours. You're just gonna have to play around to see how these things work, you can maybe use https://wiki.multitheftauto.com/wiki/SetVehicleComponentPosition, along with https://wiki.multitheftauto.com/wiki/SetVehicleComponentRotation I wish I could help more but I'm a modeler not a scripter Edited October 10, 2017 by Justin|X5| 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