Jump to content

Positioning Camera?


Guest dab

Recommended Posts

Posted

Positioning the Camera:

Ok, I'm trying to place my character at a position, and have my camera look at him there. I'm having problems getting my camera to position/look correctly:

Server:

function spawnFunct ( playerNode, inout ) 
    if (inout == 0) then 
        local dones 
        bindTheKeys( playerNode ) 
        playerSkin[ playerNode ] = 1 
        setPlayerSkin(source, PlayerClasses[ playerSkin[ source ] ]  )  
        spawnPlayer ( playerNode, 2438.6921, -54.5835,28.1535, 354.0469 ) 
        dones = setCameraMode( playerNode, "fixed" ) 
        if (dones) then 
            SendText( "Fix: Good" ) 
        else 
            SendText( "Fix: Bad" ) 
        end       
        triggerClientEvent ( "onJoin", root, playerNode )         
    end 
end 

SpawnFunct gets called everytime a player joins

Client

root = getRootElement() 
  
  
function playerJoin ( playerNode ) 
    setTimer ( setCameraPosition, 1000, 1, source, 2438.6921, -54.5835,28.1535, 354.0469 )  
    setTimer ( setCameraLookAt, 1000, 1, source, 2438.6921, -54.5835,28.1535, 354.0469 )  
    SendText( "Grrr. Did I get here?", playerNode )     
end 
addEvent("onJoin", true) 
addEventHandler("onJoin", getRootElement(), playerJoin) 
  
function SendText( text, playerid ) 
    outputChatBox( text, playerid ) 
end 

The camera does not get moved or anything. :/ What am I doing wrong?

Posted

root = getRootElement() 
  
  
function playerJoin ( playerNode ) then <---- Hm? 
    setTimer ( setCameraPosition, 1000, 1, source, 2438.6921, -54.5835,28.1535, 354.0469 )  
    setTimer ( setCameraLookAt, 1000, 1, source, 2438.6921, -54.5835,28.1535, 354.0469 )  
    SendText( "Grrr. Did I get here?", playerNode )     
end 
addEvent("onJoin", true) 
addEventHandler("onJoin", getRootElement(), playerJoin) 
  
function SendText( text, playerid ) 
    outputChatBox( text, playerid ) 
end 

Alright, I'm horrible at Lua but shouldn't there a then where I've marked?

Posted
You're lacking setCameraMode to "fixed"

function spawnFunct ( playerNode, inout ) 
    if (inout == 0) then 
        local dones 
        bindTheKeys( playerNode ) 
        playerSkin[ playerNode ] = 1 
        setPlayerSkin(source, PlayerClasses[ playerSkin[ source ] ]  )  
        spawnPlayer ( playerNode, 2438.6921, -54.5835,28.1535, 354.0469 ) 
        [u][b]dones = setCameraMode( playerNode, "fixed" )[/b][/u] 
        if (dones) then 
            SendText( "Fix: Good" ) 
        else 
            SendText( "Fix: Bad" ) 
        end       
        triggerClientEvent ( "onJoin", root, playerNode )         
    end 
end 

Question, setCameraMode can only be used server side right? :S

Posted

You can use toggleCameraFixedMode for client-side scripts.

Posted

addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), setupSpawn )

Would be to add the function setupSpawn for onClientPlayerSpawn, does that include the player yourself? LIke for when you spawn?

Posted

dab, not entirely sure what you're saying. The code you quote will call the function only when the local player spawns.

Posted

Im trying set camera with server-side scripts.But it wont wok.

  
function OnPlayerSpawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
  
    setTimer ( setCameraPosition, 1000, 1, source, -2618.9541,1414.4677,7.1016 )  
    setCameraMode ( source, "fixed" )    
    toggleAllControls ( source, false ) 
    bindKey ( source, "enter", "down", unfreezeBind ) 
  
  
end 
  
addEventHandler ( "onPlayerSpawn", getRootElement(), OnPlayerSpawn ) 
  

How can i make it work ?

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