OffRoader23 Posted February 13, 2008 Share Posted February 13, 2008 I've been looking at the camera functions and wanting to know if theres a way to make the camera an element so it can be attach to a vehicle at any x/y/z position I want. Is this possible with this version of MTA? I know I could run a timer to move the camera to the player every 50ms, but the delay of 50ms is way too long IMO, and makes the camera very jerky. I want to do this to make like, in vehicle cameras and anything like that. The camera commands don't seem to be working for me at all? I was just testing them and it would NOT change my camera, and my console returned no errors. function dropCamera (player) local x, y, z = getElementPosition ( player ) setCameraMode ( player, "player" ) setCameraPosition ( player, x, y, z ) end addCommandHandler ( "dropcamera", dropCamera) Just supposed to drop the camera in place, and follow the player, but it doesn't work on foot or in vehicle, and returns no console errors. Link to comment
eAi Posted February 13, 2008 Share Posted February 13, 2008 You want to do it client side, with the onClientRender event, toggleCameraFixedMode and setCameraPosition and setCameraLookAt. Link to comment
norby89 Posted February 13, 2008 Share Posted February 13, 2008 I experimented with this and no matter what I tried the camera was always jerky I hope someone can find a workaround or a fix for this prob Link to comment
Oli Posted February 13, 2008 Share Posted February 13, 2008 man i so need to install mta at work.. id test so many scripts each day instead of working itd be funny im gonna have a go at this later though. Link to comment
norby89 Posted February 13, 2008 Share Posted February 13, 2008 this is a simple script that places the camera above the player (GTA2 style) local root = getRootElement() local localPlayer = getLocalPlayer () local update = false function updateCameraPos() local x, y, z = getElementPosition ( localPlayer ) setCameraPosition ( x, y-1, z + 30 ) setCameraLookAt ( x, y, z ) end end function changeCamera() if ( update == false ) then update = true toggleCameraFixedMode ( true ) addEventHandler ( "onClientRender", root, updateCameraPos ) else update = false toggleCameraFixedMode ( false ) removeEventHandler ( "onClientRender", root, updateCameraPos ) end end addCommandHandler ( "cam", changeCamera ) if you wanna know what I mean by 'jerky' change this line to setCameraPosition ( x, y-1, z + 3 ) Link to comment
Woovie Posted February 15, 2008 Share Posted February 15, 2008 Woah, interesting script. So this updates the camera onClientRender, as in every frame ? Link to comment
erorr404 Posted February 18, 2008 Share Posted February 18, 2008 Yes, and the jerkiness is an issue with the camera functions not being set in the same frame, it might be fixed in the next version. Link to comment
norby89 Posted February 19, 2008 Share Posted February 19, 2008 Yes, and the jerkiness is an issue with the camera functions not being set in the same frame, it might be fixed in the next version. *pees in his pants* T_T 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