Jump to content

[Question] Getting client camera matrix


spenkbang

Recommended Posts

Posted

Can anyone tell me how this works?  I'm trying to call from the server:

getCameraMatrix( getElementsByType("player")[1] )

But it returns false.  Works fine from the client. From the docs I see the camera is updated at 500ms by default.. just not sure how to access it

Posted
51 minutes ago, spenkbang said:

Can anyone tell me how this works?  I'm trying to call from the server:


getCameraMatrix( getElementsByType("player")[1] )

But it returns false.  Works fine from the client. From the docs I see the camera is updated at 500ms by default.. just not sure how to access it 

Probably not getting the player.
Posted

inspect() shows that the player is ok. It looks like getCameraMatrix() only works after you use setCameraMatrix, so it seems not useful for getting a synced camera.   Maybe there's just no way to access the synced camera data from the server?

 

Posted
53 minutes ago, spenkbang said:

inspect() shows that the player is ok. It looks like getCameraMatrix() only works after you use setCameraMatrix, so it seems not useful for getting a synced camera.   Maybe there's just no way to access the synced camera data from the server?

 

Quote

Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).

 

Posted
4 hours ago, Peti said:

Why do you need such thing? Maybe there are other ways. 

I want to create objects at points which are not likely to be seen by players in the server.   

1 hour ago, Feche1320 said:

Call client function getCameraMatrix and return it to server

This seems to be the best option for now.  Though I'd rather use less bandwidth, not ask the client for variables which the server (seemingly) already has access to

Posted
18 hours ago, spenkbang said:

Can anyone tell me how this works?  I'm trying to call from the server:


getCameraMatrix( getElementsByType("player")[1] )

But it returns false.  Works fine from the client. From the docs I see the camera is updated at 500ms by default.. just not sure how to access it

getCameraMatrix

Shared function
 

This function gets the position of the camera and the position of the point it is facing.

Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).

Posted
14 hours ago, spenkbang said:

I want to create objects at points which are not likely to be seen by players in the server.   

This seems to be the best option for now.  Though I'd rather use less bandwidth, not ask the client for variables which the server (seemingly) already has access to

If you don't need very accurate positions, math.floor the coordinates.

Anyways, assuming MTA 'fixes' this issue, you are going to be using the same amount of bandwidth vs calling the client fix, since the server will ask the client the camera matrix constantly to have it updated on server-side

  • Discord Moderators
Posted

Math.floor-ing coordinates doesn't help: in MTA Lua is configured to use 64 bit doubles, so even an int will be represented as a 64 bit double.

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