Jump to content

animate camera move


Recommended Posts

A timer wouldn't be that smoth.

its okay if its not that smooth, so how do i do it ?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

here in this code the camera is not moving like u said it would.. it just goes instantly, am i doing something wrong ?

a,b,c = 2001.55,1914.39,40.35 
  
function cammove () 
    bindKey("arrow_l","up", 
        function() 
            outputChatBox("left") 
            face = "left" 
            setCameraMatrix ( a,b,c, 2001.99,1916.97,40.35 ) 
        end 
    ) 
  
    bindKey("arrow_d","up", 
        function() 
            outputChatBox("middle") 
            setCameraMatrix ( a,b,c, 1998.78,1914.29,40.35 ) 
            face = "middle" 
        end 
    ) 
  
    bindKey("arrow_r","up", 
        function() 
            outputChatBox("right") 
            setCameraMatrix ( a,b,c, 2001,1911.4,40.35) 
            face = "right" 
        end 
    ) 
end 
addEventHandler("onClientPreRender",getRootElement(),cammove) 

Link to comment

@aim-killer,

You're doing it wrong. DO NOT bind keys every frame! You will run out of RAM quickly. When you call bindKey, the function is stored in RAM. You're creating 3 anonymous functions and call bindKey 3 times per frame, if you're running MTA at 50fps then you're creating 150 functions each second! Also, when pressing the bound key, each function will have to be called, so after 1 second there will be 50 functions bound to 1 key, when you press that key, each function will be called.

If you want to have a server-side function to do camera animations then you can have a server-side function which will then trigger client-side event, then the event could start the camera animation. You can use one of the useful functions from wiki: https://wiki.multitheftauto.com/wiki/SmoothMoveCamera which will move the camera smoothly for you. I would use interpolateBetween which gives more functionality, instead of creating objects and moving them to the target location.

@6ArHxiMr'3a[Z]eF,

These variables don't need to be local.

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