scaryface87 Posted May 24, 2015 Share Posted May 24, 2015 Hello , I would like to update the camera every time the chair moves. I already tried something but it isnt working, it keeps looking at the same position and isnt following the object This need to be server side (or atleast the chair need to stay server side)! Also i need something to reset the camera back to normal but i dont have a clue how to do that , i tried setCameraTarget(player) but then it looks at the neck. local chair = createObject ( 1671, -1326, -67, 13355, 0, 0, 0 ) function test(player) x,y,z = getElementPosition(chair) setCameraMatrix(player,x,y,z) end addCommandHandler("test123",test) Link to comment
WhoAmI Posted May 24, 2015 Share Posted May 24, 2015 setCameraTarget ( player, chair ) Link to comment
scaryface87 Posted May 24, 2015 Author Share Posted May 24, 2015 Not working , nothing in debug Link to comment
WhoAmI Posted May 24, 2015 Share Posted May 24, 2015 Are you sure that it is s-side script? Link to comment
scaryface87 Posted May 24, 2015 Author Share Posted May 24, 2015 Jep i even tried to just create a chair and put the camera on it but i wasnt even able to Link to comment
Moderators IIYAMA Posted May 25, 2015 Moderators Share Posted May 25, 2015 local x,y,z = getElementPosition(chair) local sx,sy,sz,_,_,_ = getCameraMatrix(player) if not sx then sx,sy,sz = getElementPosition(player) end setCameraMatrix(player,sx,sy,sz,x,y,z) I don't know what you want, explain better with less nonsense. local lastPosition = {} setTimer(function () if not lastPosition then local x,y,z = getElementPosition(chair) if getDistanceBetweenPoints3D(x,y,z,lastPosition[1],lastPosition[2],lastPosition[3]) > 0.1 then outputChatBox("chair moved!") lastPosition = {x,y,z} end else lastPosition = {getElementPosition(chair)} end end,100,0) Link to comment
scaryface87 Posted May 25, 2015 Author Share Posted May 25, 2015 I want an camera looking to the chair while the chair is moving Link to comment
Moderators IIYAMA Posted May 25, 2015 Moderators Share Posted May 25, 2015 Well, combine the code from a both and you have it. But make sure you have a table with valid players you can loop through, so the variable "player" can be defined. 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