Jump to content

getCameraPosition?


jkub

Recommended Posts

im trying to use getCameraPosition in a script and it is not working it says its a nil value?

i simply want it to get the pos of the player and set the cam to fixed then set the position to the pos it got from the player

function newCam ( source ) 
    setCameraMode ( source, "fixed" ) 
    local x, y, z = getCameraPosition ( source ) 
        setCameraPosition ( source, x, y, z ) 
end 

Link to comment

getCameraPosition doesn't exist serverside - DP2 doesn't sync players' cameras to the server. If you need getCameraPosition, use a clientside script.

And just out of curiosity, what exactly is the point of getting the camera position and then immediately setting the same position again? :P

Link to comment
And just out of curiosity, what exactly is the point of getting the camera position and then immediately setting the same position again? :P

I guess so that the camera doesn't move with the player, but stays at the same position. That's what I can understand out of the code and his explanation.

Did indeed look a little weird on first watch though... ^^

Link to comment
And just out of curiosity, what exactly is the point of getting the camera position and then immediately setting the same position again? :P

I guess so that the camera doesn't move with the player, but stays at the same position. That's what I can understand out of the code and his explanation.

Did indeed look a little weird on first watch though... ^^

From what he described I understand that he wants to set camera inside of player's ass; like an FPS but camera set a bit lower then head.

Link to comment
  • 2 months later...

Camera would be flickering becausr the distance you travel between frames is so long that camera wouldn't be smooth. Someone would say "Use onClientPreRender", but what's the difference? It is still executed every frame and as I said the distance travelled between frames is too long for camera to be smooth.

Both onClientPreRender and onClientRender would have to be used but I doubt it would be smooth enough. In addition it would drop down fps on slower PCs.

Link to comment

So it's possible, but basically unpractical? I have enough trouble running MTA with my machine as it is :P

What about a flying spectator camera? like in the race editor? would that have the same issue since you are moving so fast? But I'm guessing that was done much differently than if it would be scripted?

Link to comment

It's done the same way but you don't see the camera "jumping". The problem with that camera is that onClientRender isn't triggered every frame. Maybe it is but some frames are skipped if you have too much code executed at one frame and the code is carried over to the next frame. That's what I noticed. So it's possible to make that "flying camera" and you can find it in a gamemode "fallout" (file "freecamclient.lua")

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