ViRuZGamiing Posted December 8, 2013 Share Posted December 8, 2013 I want to create like GTA V when I join the camera looks from up the air to the character and zooms in, how can i do the zoom in? local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) function setCameraOnPlayerJoin() setCameraMatrix(source, px, py, pz+50, px, py, pz) end addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) Link to comment
Moderators IIYAMA Posted December 8, 2013 Moderators Share Posted December 8, 2013 local startX,startY,startZ = 0,0,0 local endX,endY,endZ = 0,0,0 local cameraStartHighed = 50 local progress = 0 local handled = false local renderFunction renderFunction = function() setCameraMatrix(source, startX,startY,startZ-(cameraStartHighed*progress), endX,endY,endZ) progress = progress+0.02 if progress >= 1 then setCameraTarget(localPlayer) progress = 0 removeEventHandler("onClientRender",root,renderFunction) handled = false end end local setCameraOnPlayerSpawn = function () local pX,pY,pZ = getElementPosition(localPlayer) startX,startY,startZ, endX,endY,endZ= pX,pY,pZ+cameraStartHighed, pX,pY,pZ setCameraMatrix(source, startX,startY,startZ, endX,endY,endZ) if not handled then addEventHandler("onClientRender",root,renderFunction) handled = true end progress = 0 end addEventHandler("onClientPlayerSpawn", root, setCameraOnPlayerSpawn) Try this, I just wrote it in 4 min, I didn't checked it with bugs and typo's....... etc ect ect. Link to comment
Desaster Posted December 8, 2013 Share Posted December 8, 2013 local startX,startY,startZ = 0,0,0 local endX,endY,endZ = 0,0,0 local cameraStartHighed = 50 local progress = 0 local handled = false local renderFunction renderFunction = function() setCameraMatrix(startX,startY,startZ-(cameraStartHighed*progress), endX,endY,endZ) progress = progress+0.02 if progress >= 1 then setCameraTarget(localPlayer) progress = 0 removeEventHandler("onClientRender",root,renderFunction) handled = false end end local setCameraOnPlayerSpawn = function () local pX,pY,pZ = getElementPosition(localPlayer) startX,startY,startZ, endX,endY,endZ= pX,pY,pZ+cameraStartHighed, pX,pY,pZ setCameraMatrix(startX,startY,startZ, endX,endY,endZ) if not handled then addEventHandler("onClientRender",root,renderFunction) handled = true end progress = 0 end addEventHandler("onClientPlayerSpawn", root, setCameraOnPlayerSpawn) you used the server side function in client side this is the fixed one Bugs of this script every one see the camera matrix Link to comment
Moderators IIYAMA Posted December 8, 2013 Moderators Share Posted December 8, 2013 local startX,startY,startZ = 0,0,0 local endX,endY,endZ = 0,0,0 local cameraStartHighed = 50 local progress = 0 local handled = false local renderFunction renderFunction = function() setCameraMatrix(startX,startY,startZ-(cameraStartHighed*progress), endX,endY,endZ) progress = progress+0.02 if progress >= 1 then setCameraTarget(localPlayer) progress = 0 removeEventHandler("onClientRender",root,renderFunction) handled = false end end local setCameraOnPlayerSpawn = function () local pX,pY,pZ = getElementPosition(localPlayer) startX,startY,startZ, endX,endY,endZ= pX,pY,pZ+cameraStartHighed, pX,pY,pZ setCameraMatrix(startX,startY,startZ, endX,endY,endZ) if not handled then addEventHandler("onClientRender",root,renderFunction) handled = true end progress = 0 end addEventHandler("onClientPlayerSpawn", root, setCameraOnPlayerSpawn) you used the server side function in client side this is the fixed one Bugs of this script every one see the camera matrix local startX,startY,startZ = 0,0,0 local endX,endY,endZ = 0,0,0 local cameraStartHighed = 50 local progress = 0 local handled = false local renderFunction renderFunction = function() setCameraMatrix(startX,startY,startZ-(cameraStartHighed*progress), endX,endY,endZ) progress = progress+0.02 if progress >= 1 then setCameraTarget(localPlayer) progress = 0 removeEventHandler("onClientRender",root,renderFunction) handled = false end end local setCameraOnPlayerSpawn = function () local pX,pY,pZ = getElementPosition(localPlayer) startX,startY,startZ, endX,endY,endZ= pX,pY,pZ+cameraStartHighed, pX,pY,pZ setCameraMatrix(startX,startY,startZ, endX,endY,endZ) if not handled then addEventHandler("onClientRender",root,renderFunction) handled = true end progress = 0 end addEventHandler("onClientPlayerSpawn", localPlayer, setCameraOnPlayerSpawn) @Desaster thanks for testing. This will prevent it for triggering for everybody. Link to comment
ViRuZGamiing Posted December 10, 2013 Author Share Posted December 10, 2013 Is it possible that I paste a Login in front of it and change the addEventHandler to "onPlayerSpawn" ? I know it becomes Server side then. Link to comment
Desaster Posted December 10, 2013 Share Posted December 10, 2013 ye but you have to trigger it then Link to comment
ViRuZGamiing Posted December 10, 2013 Author Share Posted December 10, 2013 So you mean like this: Client: local startX,startY,startZ = 0,0,0 local endX,endY,endZ = 0,0,0 local cameraStartHighed = 50 local progress = 0 local handled = false local renderFunction renderFunction = function() setCameraMatrix(startX,startY,startZ-(cameraStartHighed*progress), endX,endY,endZ) progress = progress+0.02 if progress >= 1 then setCameraTarget(localPlayer) progress = 0 removeEventHandler("onClientRender",root,renderFunction) handled = false end end local setCameraOnPlayerSpawn = function () local pX,pY,pZ = getElementPosition(localPlayer) startX,startY,startZ, endX,endY,endZ= pX,pY,pZ+cameraStartHighed, pX,pY,pZ setCameraMatrix(startX,startY,startZ, endX,endY,endZ) if not handled then addEventHandler("onClientRender",root,renderFunction) handled = true end progress = 0 end addEvent( "setCamera", true ) addEventHandler( "setCamera", getRootElement(), setCameraOnPlayerSpawn ) Server: function serverCamera triggerClientEvent ( "setCamera", getRootElement()) end addEventHandler("onPlayerLogin", localPlayer, serverCamera) Link to comment
isa_Khamdan Posted December 10, 2013 Share Posted December 10, 2013 Server side function serverCamera() triggerClientEvent ( source ,"setCamera", source ) end addEventHandler("onPlayerLogin", getRootElement(), serverCamera) Link to comment
ViRuZGamiing Posted December 10, 2013 Author Share Posted December 10, 2013 Thx i'll try it 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