Jump to content

camera


kasya85

Recommended Posts

camera is not moving, why??

 

local posX , posY , posZ = 1349.6624,-909.8301,91.9341;
local posAtX , posAtY ,posAtZ = 180.6144,-850.0771,84.3115;

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()

local sWidth,sHeight = guiGetScreenSize()
guiCreateStaticImage (sWidth/2-200,sHeight/2-325, 400, 650, "logo.jpg", false)

toggleControl("all", false)
setPlayerHudComponentVisible("all", false)
setCameraMatrix(posX, posY, posZ, posAtX, posAtY, posAtZ)
fadeCamera(true) 

addEventHandler("onClientPreRender",  getRootElement(), cameraUpdate)


ShowCursor(true)
 
end)

function cameraUpdate()
posX = PosX + 0.3;
posAtX = posAtX + 0.3;
setCameraMatrix(posX, posY, posZ, posAtX, posAtY, posAtZ)
end

 

Edited by kasya85
Link to comment

To make the camera move smoothly from point A to B use the interpolateBetween function.

Try playing with this and test it out:

local time = 10000 --10 seconds
local start = getTickCount(  ) --the start of the interpolation
--Point A
local x,y,z = 2046.943359375, 997.03973388672, 13.485786437988
--Point B
local x2,y2,z2 = 2046.943359375, 1010, 13.485786437988


addEventHandler( "onClientRender", root, function ( )
	local progress = (getTickCount(  )-start)/time
	local x,y,z = interpolateBetween( x,y,z,x2,y2,z2, progress, "InOutQuad")-- create a new xyz of the updated position
	setCameraMatrix( x, y, z)
end )

some examples

https://streamable.com/68wwd

https://streamable.com/3z931

Edited by Mr.Loki
Link to comment

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