Jump to content

setCameraMatrix


isa_Khamdan

Recommended Posts

Well,u can . . .

create the object

moveObject

onClientRender

getElementPosition (object)

setCameraMatrix

It's easy, or u can use interpolateBetween.

Edit: https://wiki.multitheftauto.com/wiki/SmoothMoveCamera

Hmm can you help me to do it?

this is the start position

    setCameraMatrix ( 2024.8813476563, 1185.5794677734, 131.04609680176 , 2025.7608642578, 1185.3765869141, 130.61557006836, 0, 70 ) 

And from here I want to to keep moving around SA no matter where :S

Link to comment
Have you defined it?

It's from the function source code

local sm = {} 
sm.moov = 0 
sm.object1, sm.object2 = nil, nil 
  
local function removeCamHandler () 
    if(sm.moov == 1) then 
        sm.moov = 0 
        removeEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    end 
end 
  
local function camRender () 
    local x1, y1, z1 = getElementPosition ( sm.object1 ) 
    local x2, y2, z2 = getElementPosition ( sm.object2 ) 
    setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) 
end 
  
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" ) 
  
    addEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    sm.moov = 1 
    setTimer ( removeCamHandler, time, 1 ) 
    setTimer ( destroyElement, time, 1, sm.object1 ) 
    setTimer ( destroyElement, time, 1, sm.object2 ) 
    return true 
end 

That's the function I used to Remove the CamRender

function hideLoginWindow() 
    guiSetVisible(GUIEditor.window[1], false) 
    showCursor(false) 
    showChat(true) 
    showPlayerHudComponent ( "all", true ) 
    removeCamHandler () 
    setCameraTarget ( getLocalPlayer() ) 
   end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

Link to comment
And, is it in the same script? because that function is defined as local, so it won't exist outside that file.

Yes it's in the same script.

Else I am getting problem with the source code ( after the timer finish it keep showing warnings and errors cuz the objects have been destroyed but it keep checking for their position and that's mean that the RemoveCamRender have problem)

Link to comment
local sm = {} 
sm.moov = 0 
sm.object1, sm.object2 = nil, nil 
  
function removeCamHandler () 
    if(sm.moov == 1) then 
        sm.moov = 0 
        removeEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    end 
end 
  
function camRender () 
    local x1, y1, z1 = getElementPosition ( sm.object1 ) 
    local x2, y2, z2 = getElementPosition ( sm.object2 ) 
    setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) 
end 
  
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" ) 
  
    addEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    sm.moov = 1 
    setTimer ( removeCamHandler, time, 1 ) 
    setTimer ( destroyElement, time, 1, sm.object1 ) 
    setTimer ( destroyElement, time, 1, sm.object2 ) 
    return true 
end 

Try that instead.

Link to comment
local sm = {} 
sm.moov = 0 
sm.object1, sm.object2 = nil, nil 
  
function removeCamHandler () 
    if(sm.moov == 1) then 
        sm.moov = 0 
        removeEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    end 
end 
  
function camRender () 
    local x1, y1, z1 = getElementPosition ( sm.object1 ) 
    local x2, y2, z2 = getElementPosition ( sm.object2 ) 
    setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) 
end 
  
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" ) 
  
    addEventHandler ( "onClientPreRender", getRootElement(), camRender ) 
    sm.moov = 1 
    setTimer ( removeCamHandler, time, 1 ) 
    setTimer ( destroyElement, time, 1, sm.object1 ) 
    setTimer ( destroyElement, time, 1, sm.object2 ) 
    return true 
end 

Try that instead.

It's working :)

Thanks

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