developa Posted July 22, 2017 Share Posted July 22, 2017 Hi, how to setCameraMatrix camera tracking on individual players to follow them, twisted and the like? Link to comment
NeXuS™ Posted July 22, 2017 Share 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 Link to comment
developa Posted July 22, 2017 Author Share 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? Link to comment
NeXuS™ Posted July 22, 2017 Share 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 Link to comment
developa Posted July 22, 2017 Author Share Posted July 22, 2017 i have error bad argument @setCameraMatrix [expected vector3 at argument 4, got boolean] Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 Do you have an element called 'ped'? 1 Link to comment
developa Posted July 22, 2017 Author Share Posted July 22, 2017 I have it, but it does not set me a camera Link to comment
developa Posted July 22, 2017 Author Share 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) Link to comment
developa Posted July 22, 2017 Author Share Posted July 22, 2017 yes, about five, ten meters away from him Link to comment
NeXuS™ Posted July 22, 2017 Share 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) Link to comment
NeXuS™ Posted July 22, 2017 Share 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? Link to comment
NeXuS™ Posted July 22, 2017 Share 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) Link to comment
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