Jump to content

Need help with a cameraMatrix.


Clydian

Recommended Posts

So i have a simple login, theres a picture in background. I want to change the picture, to a flying camera effect around Los Santos. How do i do that? I can just make it look at one position.

fadeCamera ( false, 0, 0,0,0 ) 
        setCameraMatrix (1217.103515625, -1307.1328125, 52.016986846924, 1131.939453125, -1352.66796875, 49.851699829102) 
        setTimer(function () 
            fadeCamera ( true, 1, 0,0,0 ) 
        end, 1000, 1) 

This make the camera near LSPD and looks at a fountain. I want the camera to rotate around the fountain.

Link to comment

But why douesnt this work?

local sm = {} 
sm.moov = 0 
sm.object1,sm.object2 = nil,nil 
  
local function removeCamHandler() 
    if(sm.moov == 1)then 
        sm.moov = 0 
    end 
end 
  
local function camRender() 
    if (sm.moov == 1) then 
        local x1,y1,z1 = getElementPosition(sm.object1) 
        local x2,y2,z2 = getElementPosition(sm.object2) 
        setCameraMatrix(x1,y1,z1,x2,y2,z2) 
    end 
end 
addEventHandler("onClientPreRender",root,camRender) 
  
function smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time) 
    if(sm.moov == 1)then return false end 
    sm.object1 = createObject(1337,x1,y1,z1) 
    sm.object2 = createObject(1337,x1t,y1t,z1t) 
    setElementAlpha(sm.object1,0) 
    setElementAlpha(sm.object2,0) 
    setObjectScale(sm.object1,0.01) 
    setObjectScale(sm.object2,0.01) 
    moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad") 
    moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad") 
    sm.moov = 1 
    setTimer(removeCamHandler,time,1) 
    setTimer(destroyElement,time,1,sm.object1) 
    setTimer(destroyElement,time,1,sm.object2) 
    return true 
end 
  
  
fadeCamera ( false, 0, 0,0,0 ) 
smoothMoveCamera (1715.978515625, -1732.900390625, 19.510538101196, 1750.73046875, -1732.919921875, 15.30633354187, 1814.8818359375, -1732.6376953125, 28.479869842529, 1750.73046875, -1732.919921875, 15.30633354187, 1) 
setTimer(function () 
    fadeCamera ( true, 1, 0,0,0 ) 
end, 1000, 1) 

Link to comment
At time you need to set at least 50 ms, because
setTimer 

needs a minimum of 50 ms.

Use your code in a function like

onClientResourceStart 

I set the Timer to 50 but it didnt change nothing.

Where do you want me to put "onClientResourceStart"?

EDIT: i set it to 5000 and it works. So thats fixed. Thanks.

And theres another thing, basicly when the camera moves to that x2,y2,z2, can i somehow make that the camera moves somewhere else?

Link to comment

onClientResourceStart is an event, use it like this:

addEventHandler( "onClientResourceStart", getRootElement( ), 
    function ( startedRes ) 
        outputChatBox( "Resource started: " .. getResourceName( startedRes ) ) 
    end 
) 

And theres another thing, basicly when the camera moves to that x2,y2,z2, can i somehow make that the camera moves somewhere else?

Use a table, for loop and setTimer to make this

  
local cameraPos = { 
    [1] = {0, 0, 0, 2, 2, 2} 
    [2] = {2, 2, 2, 0, 0, 0} 
} 
  
cameraTimerPosition = 0 
for _, position in ipairs(cameraPos) do 
    cameraTimerPosition = cameraTimerPosition + 10000 
    setTimer(moveCamera, cameraTimerPosition, 1, position) 
end 
  
function moveCamera(position) 
    local x, y, z, lx, ly, lz = getCameraMatrix() 
    smoothMoveCamera(x, y, z, lx, ly, lz, position[1], position[2], position[3], position[4], position[5], position[6], 1000) 
end 

Link to comment
onClientResourceStart is an event, use it like this:
addEventHandler( "onClientResourceStart", getRootElement( ), 
    function ( startedRes ) 
        outputChatBox( "Resource started: " .. getResourceName( startedRes ) ) 
    end 
) 

And theres another thing, basicly when the camera moves to that x2,y2,z2, can i somehow make that the camera moves somewhere else?

Use a table, for loop and setTimer to make this

  
local cameraPos = { 
    [1] = {0, 0, 0, 2, 2, 2} 
    [2] = {2, 2, 2, 0, 0, 0} 
} 
  
cameraTimerPosition = 0 
for _, position in ipairs(cameraPos) do 
    cameraTimerPosition = cameraTimerPosition + 10000 
    setTimer(moveCamera, cameraTimerPosition, 1, position) 
end 
  
function moveCamera(position) 
    local x, y, z, lx, ly, lz = getCameraMatrix() 
    smoothMoveCamera(x, y, z, lx, ly, lz, position[1], position[2], position[3], position[4], position[5], position[6], 1000) 
end 

Cheers lad. Cookie to you :)

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