Jump to content

Camera Functions


OffRoader23

Recommended Posts

Posted

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.

Posted

You want to do it client side, with the onClientRender event, toggleCameraFixedMode and setCameraPosition and setCameraLookAt.

Posted

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

Posted

man i so need to install mta at work.. id test so many scripts each day instead of working itd be funny :P im gonna have a go at this later though.

Posted

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 ) 

Posted

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.

Posted
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

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