Jump to content

360* Camera


Recommended Posts

try this:
local facing = 0 
local distance = 5; 
local height = 1; 
local speed = 0.0002 
  
function rotateCameraAroundPlayer() 
    local x, y, z = getElementPosition(localPLyer) 
    if isPedInVehicle(localPlayer) then 
        x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
    end 
    local camX = x + math.cos(facing / math.pi * 180) * distance; 
    local camY = y + math.sin(facing / math.pi * 180) * distance; 
    setCameraMatrix(camX, camY, z + height, x, y, z) 
    facing = facing + 0.0002 
end 
  
function startRotatingCamera() 
    addEventHandler("onClientPreRender", root, rotateCameraAroundPlayer) 
end 
  
function stopRotatingCamera() 
    removeEventHandler("onClientPreRender", root, rotateCameraAroundPlayer) 
end 
  
addEventHandler("onClientResourceStart", resourceRoot,function() --Use onClientResourceStart for localPlayer 
    fadeCamera(true, 3) --no need for source if the client is localPlayer 
    startRotatingCamera() 
    setPlayerNametagColor(0, 204, 0) --If it's client-side, don't add source 
end) 

I add comments to let you know the stuff your missing

You has a error on line 7

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