developa Posted July 22, 2017 Posted July 22, 2017 Hi, how to setCameraMatrix camera tracking on individual players to follow them, twisted and the like?
NeXuS™ Posted July 22, 2017 Posted July 22, 2017 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. 1
developa Posted July 22, 2017 Author Posted July 22, 2017 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?
NeXuS™ Posted July 22, 2017 Posted July 22, 2017 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. 1
developa Posted July 22, 2017 Author Posted July 22, 2017 i have error bad argument @setCameraMatrix [expected vector3 at argument 4, got boolean]
developa Posted July 22, 2017 Author Posted July 22, 2017 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)
NeXuS™ Posted July 22, 2017 Posted July 22, 2017 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)
NeXuS™ Posted July 22, 2017 Posted July 22, 2017 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?
NeXuS™ Posted July 22, 2017 Posted July 22, 2017 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now