Jump to content

[HELP] Car Rotation


MatreN

Recommended Posts

  • Moderators
  On 19/09/2019 at 15:35, MatreN said:

How do I turn an infernus 360 degrees?

Expand  

You can also change the rotate (velocity) with this function:

https://wiki.multitheftauto.com/wiki/SetElementAngularVelocity

 

But for exact 360, you will need the setElementRotation function.

It just depends on what you are going to make.

 

Edited by IIYAMA
Link to comment
  • Moderators
  On 19/09/2019 at 23:17, MatreN said:

I'll make a showroom-style system.

Expand  

A small example/hack to rotate (multiple) vehicles. With very little code.

 

This code is untested

local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount() % duration) / duration * 360 )
end)

 

 

local vehicle1 = createVehicle(--[[ fill in]])
setElementParent(vehicle1, rotationElement)



local vehicle2 = createVehicle(--[[ fill in]])
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(--[[ fill in]])
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, true)

 

  • Like 1
Link to comment
local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

Link to comment
  On 20/09/2019 at 16:44, MatreN said:

local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

Expand  

are you talk about 360 auto ? or only one?

Link to comment
  • Moderators
  On 20/09/2019 at 16:44, MatreN said:
local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

Expand  

Clientside?

 

Btw you are missing an argument: (model)

createVehicle ( int model, float x, float y, float z

 

 

 

Edited by IIYAMA
Link to comment
  • Moderators
  On 20/09/2019 at 20:19, MatreN said:

(int model) will be replaced with vehicle name?

Expand  

Is your issue now solved with xFabel his explanation?

 

You can convert names to id's with this function:

https://wiki.multitheftauto.com/wiki/GetVehicleModelFromName

 

local model = getVehicleModelFromName ("bandito")

if model then -- is there an id based on that name?
  
  
end

 

 

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...