isa_Khamdan Posted October 8, 2013 Posted October 8, 2013 I set a Camera Matrix on a selected position. My question is how can I make it move around the area?
WASSIm. Posted October 8, 2013 Posted October 8, 2013 I set a Camera Matrix on a selected position. My question is how can I make it move around the area? interpolateBetween
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 I set a Camera Matrix on a selected position. My question is how can I make it move around the area? interpolateBetween Hmm I didn't understand how to get these floats
HunT Posted October 8, 2013 Posted October 8, 2013 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
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 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
HunT Posted October 8, 2013 Posted October 8, 2013 Use this one https://wiki.multitheftauto.com/wiki/SmoothMoveCamera
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 Use this one https://wiki.multitheftauto.com/wiki/SmoothMoveCamera It works One last question , how can I stop it?
WASSIm. Posted October 8, 2013 Posted October 8, 2013 It works One last question , how can I stop it? stopObject
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 It works One last question , how can I stop it? stopObject No I mean how can I stop the whole function
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 removeCamHandler () attemp to call global 'removeCamHandler'(a nill value)
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 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)
Castillo Posted October 8, 2013 Posted October 8, 2013 And, is it in the same script? because that function is defined as local, so it won't exist outside that file.
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 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)
Castillo Posted October 8, 2013 Posted October 8, 2013 If it's the same script, then that error shouldn't happen.
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 If it's the same script, then that error shouldn't happen. Then how I am getting this error?
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 I removed local and it's working now
Castillo Posted October 8, 2013 Posted October 8, 2013 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.
isa_Khamdan Posted October 8, 2013 Author Posted October 8, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now