aim-killer Posted July 6, 2013 Share Posted July 6, 2013 Is there a way to animate the camera move from one lookAt position to another lookAt position ? i mean by setCameraMatrixfrom one lookAt x,y,z to another lookAt x,y,z in a smooth way.. not like in an instant, i hope you get what i mean Link to comment
Castillo Posted July 6, 2013 Share Posted July 6, 2013 You can use setCameraMatrix with onClientPreRender. Link to comment
aim-killer Posted July 6, 2013 Author Share Posted July 6, 2013 thanks but is there any way to do it in Server Side ? Link to comment
Castillo Posted July 6, 2013 Share Posted July 6, 2013 A timer wouldn't be that smoth. Link to comment
aim-killer Posted July 6, 2013 Author Share Posted July 6, 2013 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
iMr.3a[Z]eF Posted July 6, 2013 Share Posted July 6, 2013 @aim-killer: you missed local at the begin of "a,b,c" Link to comment
50p Posted July 7, 2013 Share Posted July 7, 2013 @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
aim-killer Posted July 8, 2013 Author Share Posted July 8, 2013 Thanks 50p, i guess its best if i use interpolateBetween , however i am not quite sure how it works yet.. anyways thanks for the clarification ^^ 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