Jump to content

Side Camera


Enigma666

Recommended Posts

Posted

Hi.

Is something like this possible in MTA?

0rgvH2u.png

Im talking about the camera being a little offset and not centered [not when shooting, by default], if so, is it also possible to make it work with the default camera rotation?

Thanks.

Posted
  
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 
  
addEventHandler("onClientRender", getRootElement(),  
    function()  
        local x,y,z = getPositionFromElementOffset(localPlayer, 0.5, -3, 0.5) 
        setCameraMatrix(x, y, z, x, y, z) 
    end 
) 
  

I have this. works fine as i said, but if i press D for example when im standing, the camera doesnt follow the players rotation to the angle, and idk which part of the matrix is supposed to do that.

Posted

Ah you mean when the ped rotates to make the camera follow him?

Try this, i'm not sure thought.

  
  
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 
  
addEventHandler("onClientRender", getRootElement(), 
    function() 
        local _,_,rot = getElementRotation(localPlayer) 
local max = 3 
local angle = math.rad(rot+90) -- +90 to actually make it from the "back" of the ped. 
local plusX,plusY = math.cos(angle)*max,math.sin(angle)*max 
        local x,y,z = getPositionFromElementOffset(localPlayer, 0.5 + plusX, -3 + plusY, 0.5) 
        setCameraMatrix(x, y, z, x, y, z) 
    end 
) 
  

Posted
Doesnt work sadly.

Try this. it should have an effect upon moving the ped...

  
  
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 
  
addEventHandler("onClientRender", getRootElement(), 
    function() 
        local _,_,rot = getElementRotation(localPlayer) 
local max = 3 
local angle = math.rad(rot+90) -- +90 to actually make it from the "back" of the ped. 
local plusX,plusY = math.cos(angle)*max,math.sin(angle)*max 
        local x,y,z = getPositionFromElementOffset(localPlayer,plusX,plusY, 0.5) 
        setCameraMatrix(x, y, z, x, y, z) 
    end 
) 
  

Posted
i think the camera rotates, but keeps looking at the position it was looking at before the rotation.

Aaaah i see. It was your bad. You didnt defined Look at XYZ. Check for some matrices on how to find the front of the ped to aim and then add an extra rotation according to aim

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