Jump to content

setCameraMatrix


xMKHx

Recommended Posts

Well actually i have an object flying in the air and there is players on it, so i just want to make a camera matrix on that object while it moving

here is an example for my work

object = createObject ( id, x, y, z, rX, rY, rZ)

local x, y, z = getElementPosition(object)

function test ()

moveObject(object, 10000, xB, yB, zB)

setCameraMatrix(localPlayer, 111, 222, 333, x, y, z)

end

addCommandHandler("setCamera", test)

I have tried setCameraTarget but nothing, i want to make the camera too far from the object, the object its like a plane or something like that, and the players are inside it, And Thank You

Link to comment
  • Moderators

Use this event to update the position every frame(frames per second):

https://wiki.multitheftauto.com/wiki/OnClientRender

 

Example on that page:

Quote

Example

This example makes the camera follow the player in a GTA2-like way. This will be a little bit laggy. If you want the camera to follow something (eg. player or vehicle) then use onClientPreRender instead.


function updateCamera ()
	local x, y, z = getElementPosition ( localPlayer )
	setCameraMatrix ( x, y, z + 50, x, y, z )
end
addEventHandler ( "onClientRender", root, updateCamera )

 

 

Instead of using the localPlayer, use the object:

local x, y, z = getElementPosition ( object )

 

  • Like 1
Link to comment
On 8/27/2018 at 19:22, IIYAMA said:

Use this event to update the position every frame(frames per second):

https://wiki.multitheftauto.com/wiki/OnClientRender

 

Example on that page:

 

Instead of using the localPlayer, use the object:


local x, y, z = getElementPosition ( object )

 

 

I've used this method but nothing no results

function CameraMatrix ()
setCameraMatrix(localPlayer, x, y, z + 20, x, y, z)
end

function move ()
moveObject ( object, 40000, -2837.884765625, -3147.1728515625, 666.09998 )
addEventHandler ( "onClientRender", root, CameraMatrix )
end
addCommandHandler("move", move)

 

Link to comment
  • Moderators

That is not the correct syntax for setCameraMatrix clientside.

 

Serverside

bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )

 

Clientside

bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )

In clientside you do not define the player, because a client(a player) can't change other players(clients) their camera. So that option has been left out.

 

 

Try this:

function CameraMatrix ()
	local x, y, z = getElementPosition ( object )
	setCameraMatrix(x, y, z + 5, x, y + 20, z + 5)
end

function move ()
	moveObject ( object, 40000, -2837.884765625, -3147.1728515625, 666.09998 )
	addEventHandler ( "onClientRender", root, CameraMatrix )
end
addCommandHandler("move", move)

 

(if nothing happens, it might be possible that you run the script serverside)

Edited by IIYAMA
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...