Jump to content

[HELP] car exhaust blast


Recommended Posts

 

While the camera of the vehicle changes, the position of the exhaust also changes, but I want it to be upright, can you help?

my problem: 

 

This is exactly how I want it to be;

4ly70ww.png

codes:

local shader = dxCreateShader("shaders/shader.fx")
local texture = dxCreateTexture("fire.dds")
dxSetShaderValue(shader,"gTexture0",texture)

local rotx,roty,roz = 0.8,1,0.2
local state = false
       
function draw()
    if state == false then return end
    vehicle = localPlayer.vehicle
    if vehicle then
         ox, oy, oz = getVehicleComponentPosition(vehicle,"exhaust")
         x,y,z = getPositionFromElementOffset(vehicle,ox,oy-0.5,oz)
    end
    size = 1
    startx = x+size
    starty = y+size-0.5
    startz = z 
    endx = x-size
    endy = y-size
    endz = z
    dxDrawMaterialLine3D(startx,starty,startz,endx,endy,endz,shader,size*2,tocolor(255,255,255,255),x-rotx,y-roty,z-roz)
end
addEventHandler("onClientPreRender",root,draw)
function visible(bool)
    state = bool 
end
function getPositionFromElementOffset(element,offX,offY,offZ)
    local m = getElementMatrix ( element ) 
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]
    return x, y, z                               
end

 

@srslyyyy

@srslyyyy

Edited by Serius
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...