Jump to content

[HELP]SetCameraMatrix


ViRuZGamiing

Recommended Posts

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
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
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 :D

Bugs of this script every one see the camera matrix

Link to comment
  • Moderators
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

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

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