jkub

getCameraPosition?

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 

Share this post


Link to post

If you're using the latest server (Nightly build) then it's setCameraMatrix and getCameraMatrix.

If you want to get player's position you need to use getElementPosition (I can't see it in your code).

Share this post


Link to post

i just tryed the matrix thing instead and it does the same exact thing wich gives me that attempt to call global getCameraMatrix (a nil value) ?

Share this post


Link to post

Make sure you get the latest build (current revision is 77). Also setCameraMode does no longer exist. You must use setCameraTarget to go back to chasing mode afaik.

Share this post


Link to post

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

Share this post


Link to post
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... ^^

Share this post


Link to post
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.

Share this post


Link to post

I was wondering if it would be hard to place the camera to a player so you can walk around like in an FPS game, and wonder how well it would work, or if it would be awkward :?

So has anyone ever tried this before? I'm posting here instead of making a new topic 8)

Share this post


Link to post

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.

Share this post


Link to post

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?

Share this post


Link to post

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")

Share this post


Link to post

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.