this will let you scroll the mouse to zoom in and out -press 'E' to reset the camera to move again
you can also hold 'E' to move the camera up and back a little to show how to do a fixed camera position.
should be enough there to show you how to achieve whatever it is you are trying to do
obviously this is just a very quick and dirty way of doing it - the best way would be to rewrite the core logic as amen suggests but don't expect it to be quick or easy
function camera_control_init(e)
end
local mod = math.modf
local distspeed = 0.2
local heightspeed = 0.3
local zoom, zooming, oldzooming, czdist, czheight = 0, 0, nil, 0, 0
local ttx, tty, ttz, tax, tay, taz, tda, tcamdist, tcamheight, tfx, tfy, tfz
function camera_control_main(e)
if oldzooming == nil then
oldzooming = g_MouseWheel
end
zooming = oldzooming - g_MouseWheel
oldzooming = g_MouseWheel
if zooming ~= 0 then
ttx=GetPlrObjectPositionX()
tty=GetPlrObjectPositionY()-35.0
ttz=GetPlrObjectPositionZ()
czdist = czdist + (zooming * distspeed)
czheight = czheight + (zooming * heightspeed)
--Prompt(czdist.." , "..czheight)
tcamdist=GetGamePlayerControlThirdpersonCameraDistance() + czdist
tcamheight=GetGamePlayerControlThirdpersonCameraHeight() + czheight
tda=WrapValue(180-(0-GetCameraAngleY(0)))
tax=(math.sin(math.rad(tda))*tcamdist)
tfx=ttx+tax
tay=tcamheight
tfy=tty+tay
taz=(math.cos(math.rad(tda))*tcamdist)
tfz=ttz+taz
else
if g_KeyPressE == 1 then
if zoom == 0 then
ttx=GetPlrObjectPositionX()
tty=GetPlrObjectPositionY()-35.0
ttz=GetPlrObjectPositionZ()
tcamdist=GetGamePlayerControlThirdpersonCameraDistance() + 20
tcamheight=GetGamePlayerControlThirdpersonCameraHeight() + 40
tda=WrapValue(180-(0-GetCameraAngleY(0)))
tax=(math.sin(math.rad(tda))*tcamdist)
tfx=ttx+tax
tay=tcamheight
tfy=tty+tay
taz=(math.cos(math.rad(tda))*tcamdist)
tfz=ttz+taz
zoom = 1
end
elseif zoom == 1 then
zoom = 0
SetCameraOverride(zoom)
end
end
if zoom == 1 or zooming ~= 0 then
SetCameraOverride(1)
PositionCamera ( 0,tfx,tfy,tfz )
PointCamera ( 0,ttx,tty,ttz )
end
end