Jump to content

Camera


developa

Recommended Posts

Posted

You have to use a timer or an event which is called every frame (onClientPreRender is what I would use).

If you want have a fix position for the cam pos, you can just get the player's pos every time when the functions is called, and then set the camera matrix with the fix pos and the player's pos.

  • Like 1
Posted
function followPed()
	local position = {getElementPosition(localPlayer)}
	local pedPosition = {getElementPosition(ped)}
	setCameraMatrix(position[1], position[2], position[3], pedPosition[1], pedPosition[2], pedPosition[3])
end
addEventHandler("onClientPreRender", root, followPed)

 

something like this?

Posted

Yep, just like that. I mean, if you want the camera to be in an exact pos, you can just change

local position = {getElementPosition(localPlayer)}

to a fix one, and then it would be a static cam which would follow a ped. If you need further help, feel free to ask.

  • Like 1
Posted
ped = createPed(135, 361.39, 171.45, 1025.79, 180)
setElementDimension(ped, 5)
setElementInterior(ped, 3)

function followPed()
	local position = {getElementPosition(localPlayer)}
	local pedPosition = {getElementPosition(ped)}
	setCameraMatrix(position[1], position[2], position[3], pedPosition[1], pedPosition[2], pedPosition[3])
end
addEventHandler("onClientPreRender", followPed)

 

Posted

What does this output?
 

ped = createPed(135, 361.39, 171.45, 1025.79, 180)
setElementDimension(ped, 5)
setElementInterior(ped, 3)

function followPed()
	outputChatBox(tostring(isElement(ped))
	--local position = {getElementPosition(localPlayer)}
	--local pedPosition = {getElementPosition(ped)}
	--setCameraMatrix(position[1], position[2], position[3], pedPosition[1], pedPosition[2], pedPosition[3])
end
addEventHandler("onClientPreRender", followPed)

 

Posted
ped = createPed(135, 361.39, 171.45, 1025.79, 180)
setElementDimension(ped, 5)
setElementInterior(ped, 3)

function followPed()
	outputChatBox(tostring(isElement(ped))
	local position = {getElementPosition(localPlayer)}
	local pedPosition = {getElementPosition(ped)}
	outputChatBox("X: " .. position[1] .. " Y: " .. position[2] .. " Z: " .. position[3])
	outputChatBox("PedX: " .. pedPosition[1] .. " PedY: " .. pedPosition[2] .. " PedZ: " .. pedPosition[3])
	--setCameraMatrix(position[1], position[2], position[3], pedPosition[1], pedPosition[2], pedPosition[3])
end
addEventHandler("onClientPreRender", followPed)

Does this output everything?

Posted

It works just fine for me mate.

ped = createPed(135, 361.39, 171.45, 1025.79, 180)
setElementDimension(ped, 5)
setElementInterior(ped, 3)

function followPed()
	outputChatBox(tostring(isElement(ped)))
	local position = {getElementPosition(localPlayer)}
	local pedPosition = {getElementPosition(ped)}
	outputChatBox("X: " .. position[1] .. " Y: " .. position[2] .. " Z: " .. position[3])
	outputChatBox("PedX: " .. pedPosition[1] .. " PedY: " .. pedPosition[2] .. " PedZ: " .. pedPosition[3])
	setCameraMatrix(position[1], position[2], position[3], pedPosition[1], pedPosition[2], pedPosition[3])
end
addEventHandler("onClientPreRender", root, followPed)

 

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