Fabioxps Posted April 18, 2013 Share Posted April 18, 2013 all right but when you press f6 camera not back to the start why? local visible = true setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) local progress = 0.0; function aa() if progress < 1 then progress = progress + 0.002; -- increase to move the camera faster end local x, y, z = interpolateBetween( 117.5101852417, 163.30557250977, 5579.2065429688, 120.94383239746,162.29713439941,5579.5678710938, progress, "Linear" ); setCameraMatrix (x, y, z, 116.48139190674, 156.49519348145, 5579.0087890625) end addEventHandler("onClientRender",root, aa) bindKey("F6","down", function() if visible then removeEventHandler("onClientRender",root, aa) visible = false else addEventHandler("onClientRender",root, aa) visible = true end end) Link to comment
Renkon Posted April 18, 2013 Share Posted April 18, 2013 Whn you press F6 again it will stay on it own position Link to comment
Fabioxps Posted April 18, 2013 Author Share Posted April 18, 2013 I want to go back to the beginning Link to comment
OGF Posted April 18, 2013 Share Posted April 18, 2013 Try this. bindKey("F6","down", function() if visible == true then removeEventHandler("onClientRender",root, aa) setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) visible = false else addEventHandler("onClientRender",root, aa) visible = true end end) Link to comment
Castillo Posted April 18, 2013 Share Posted April 18, 2013 You must return the camera to the local player using setCameraTarget. local visible = true setCameraMatrix ( 117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625 ) local progress = 0.0; function aa ( ) if ( progress < 1 ) then progress = progress + 0.002; -- increase to move the camera faster end local x, y, z = interpolateBetween ( 117.5101852417, 163.30557250977, 5579.2065429688, 120.94383239746,162.29713439941,5579.5678710938, progress, "Linear" ); setCameraMatrix ( x, y, z, 116.48139190674, 156.49519348145, 5579.0087890625 ) end addEventHandler ( "onClientRender", root, aa ) bindKey ( "F6", "down", function ( ) if ( visible ) then removeEventHandler ( "onClientRender", root, aa ) setCameraTarget ( localPlayer ) visible = false else addEventHandler ( "onClientRender", root, aa ) visible = true end end ) Link to comment
Fabioxps Posted April 18, 2013 Author Share Posted April 18, 2013 You must return the camera to the local player using setCameraTarget. local visible = true setCameraMatrix ( 117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625 ) local progress = 0.0; function aa ( ) if ( progress < 1 ) then progress = progress + 0.002; -- increase to move the camera faster end local x, y, z = interpolateBetween ( 117.5101852417, 163.30557250977, 5579.2065429688, 120.94383239746,162.29713439941,5579.5678710938, progress, "Linear" ); setCameraMatrix ( x, y, z, 116.48139190674, 156.49519348145, 5579.0087890625 ) end addEventHandler ( "onClientRender", root, aa ) bindKey ( "F6", "down", function ( ) if ( visible ) then removeEventHandler ( "onClientRender", root, aa ) setCameraTarget ( localPlayer ) visible = false else addEventHandler ( "onClientRender", root, aa ) visible = true end end ) but the camera is not coming back to the beginning castilho Link to comment
Fabioxps Posted April 18, 2013 Author Share Posted April 18, 2013 Beginning of what? the interpolateBetween only works when I start the resource in Link to comment
OGF Posted April 18, 2013 Share Posted April 18, 2013 You mean return to the initial position of the camera? That is the code I gave you. Link to comment
Fabioxps Posted April 18, 2013 Author Share Posted April 18, 2013 (edited) You mean return to the initial position of the camera? That is the code I gave you. the interpolateBetween only works when I start the resource in Edited April 18, 2013 by Guest Link to comment
OGF Posted April 19, 2013 Share Posted April 19, 2013 Still not 100% sure what your asking but I assume it might be this. bindKey("F6","down", function() if visible == true then x, y, z = nil, nil, nil progress = 0 setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) visible = false removeEventHandler("onClientRender",root, aa) else addEventHandler("onClientRender",root, aa) visible = true end end) Link to comment
Fabioxps Posted April 19, 2013 Author Share Posted April 19, 2013 Still not 100% sure what your asking but I assume it might be this. bindKey("F6","down", function() if visible == true then x, y, z = nil, nil, nil progress = 0 setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) visible = false removeEventHandler("onClientRender",root, aa) else addEventHandler("onClientRender",root, aa) visible = true end end) solved thank OGF and Castilho 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