Jump to content

Random camera positions


Recommended Posts

I'm not sure that would work couse I'm doin it for first tiem, but

cameraPosition = { 
    -- x, y, z, lookAtX, lookAtY, lookAtZ 
    { 0, 0, 0, 1, 1, 1 }, 
    { 1, 1, 1, 2, 2, 2 } 
} 
minutes = 5 -- after how many minutes cameraMatrix should change 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        fadeCamera ( source, true ) 
        local randomPos = cameraPosition [ math.random ( #cameraPosition ) ] 
        setCameraMatrix ( source, randomPos [ 1 ], randomPos [ 2 ], randomPos [ 3 ], randomPos, [ 4 ], randomPos [ 5 ], randomPos [ 6 ] ) 
         
        local timer = setTimer ( 
                          function ( ) 
                              local table = cameraPosition [ math.random ( #cameraPosition ) ] 
                              setCameraMatrix ( source, table [ 1 ], table [ 2 ], table [ 3 ], table, [ 4 ], table [ 5 ], table [ 6 ] ) 
                          end, 
                      minutes * 60000, 0 ) 
        setElementData ( source, "joiningTimer", timer ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( ) 
        fadeCamera ( source, false ) 
        local timer = getElementData ( source, "joiningTimer" ) 
        if ( isTimer ( timer ) ) then 
            killTimer ( timer ) 
        end 
    end 
) 

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