tommymaster Posted December 6, 2017 Share Posted December 6, 2017 Hi. smoothMoveCamera() (https://wiki.multitheftauto.com/wiki/SmoothMoveCamera) will re-set it's camera position whenever i would set another camera matrix. How could i break this? For example the smoothCam effect's duration is 60 seconds, but after it's start 37 seconds goes by, and an other resource would set the camera target to the local player. (But ofc immediately it resets the camera's position where it was during smoothmove camera guess it's due to it's render event.) Link to comment
quindo Posted December 7, 2017 Share Posted December 7, 2017 You can replace original smoothMoveCamera implementation with this, and use stopSmoothMoveCamera() to break the movement at any time. I didn't test it, but it should work. local sm = {} sm.moov = 0 sm.object1,sm.object2 = nil,nil sm.timer1,sm.timer2,sm.timer3 = nil,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 sm.timer1 = setTimer(removeCamHandler,time,1) sm.timer2 = setTimer(destroyElement,time,1,sm.object1) sm.timer3 = setTimer(destroyElement,time,1,sm.object2) return true end function stopSmoothMoveCamera() if isTimer( sm.timer1 ) then killTimer( sm.timer1 ) end if isTimer( sm.timer2 ) then killTimer( sm.timer2 ) end if isTimer( sm.timer3 ) then killTimer( sm.timer3 ) end if isElement( sm.object1 ) then destroyElement( sm.object1 ) end if isElement( sm.object2 ) then destroyElement( sm.object2 ) end removeCamHandler() end 1 Link to comment
tommymaster Posted December 7, 2017 Author Share Posted December 7, 2017 works, thanks!!!! Link to comment
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