Jump to content

Help about camera on top of player


Flameeagle

Recommended Posts

Hello all! i am making a script and i have made a checkbox named "topview". I want to make the camera look at the player from the top like in GTA2 when this checkbox is checked.. how can i do that? have tried with Timer.. its working but does not work with onClientRender.. btw i am using it in a Client Side script. I also want that when that checkbox is unchecked, the camera will return to the default using setCameraTarget().. i got the last part but cant make it attached to the top of the player and rotate it as the player rotates.. any help will be appreciated. Thanks.

Link to comment

The onGuiClick part:

addEventHandler("onClientGUIClick",topview,function() 
    setTimer(function() 
    if guiCheckBoxGetSelected(topview)then 
    local up = guiCreateButton(0.32, 0.05, 0.14, 0.03, "+", true, constructionsWindow) 
    guiSetProperty(up, "NormalTextColour", "FFAAAAAA") 
    local down = guiCreateButton(0.49, 0.05, 0.14, 0.03, "-", true, constructionsWindow) 
    guiSetProperty(down, "NormalTextColour", "FFAAAAAA")     
    isLookingUp = true 
    lp=getLocalPlayer() 
    --timer=setTimer(topviewer,51,0) 
    addEventHandler("onClientRender",lp,topviewer) 
    outputChatBox("DEBUG: callling...done") 
    else 
    isLookingUp = false 
--killTimer(timer) 
    setCameraTarget(localPlayer) 
    removeEventHandler("onClientRender",getLocalPlayer(),topviewer) 
     
    end 
    end,100,1) 
end,false) 

The functions:

  
function topviewer() 
outputChatBox("DEBUG: Cam changed!") 
local x, y, z = getElementPosition ( localPlayer ) 
    setCameraMatrix(x,y,z+25,x,y,z) 
end 

Link to comment

status Update: I have finally made it to work, but the controls are kinda f**ked up, what do i do? the camera is sticked to the player but the controls are like.. W for north, S for south, A for west and D for east, how do i fix it?

Also i would like to allow the player to move

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