Jump to content

setVehicleComponentRotation Problem


Karuzo

Recommended Posts

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

 

  • Like 1
Link to comment
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
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:

Bildergebnis für camber

 

Did you also check the handlings? There might be a handling option to change that angle.

Link to comment

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.

  • Like 2
Link to comment
  • 4 months later...

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 xD

Edited by Justin|X5|
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...