Moderators IIYAMA Posted March 14, 2013 Moderators Share Posted March 14, 2013 What is the best way to move the camera from one point to another? (I am talking about math) Of course I have to put it on client Render. setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) local posX, posY,posZ = 120.94383239746,162.29713439941,5579.5678710938-- location2 addEventHandler("onClientRender",root, function () local xU, yU, zU, xUt, yUt, zUt = getCameraMatrix() setCameraMatrix (xU, yU, zU, 116.48139190674, 156.49519348145, 5579.0087890625) end) Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 You can use interpolateBetween function that is very useful for your problem. https://wiki.multitheftauto.com/wiki/InterpolateBetween setCameraMatrix (117.5101852417, 163.30557250977, 5579.2065429688, 116.48139190674, 156.49519348145, 5579.0087890625) local progress = 0.0; -- value between 0 and 1 will be used to get the new position of camera (0.5 will be half way through between the 2 points) addEventHandler("onClientRender",root, function () if progress < 1 then progress = progress + 0.002; -- increase to move the camera faster end local x, y, z = interpolateBetween( 117.5101852417, 163.30557250977, 5579.2065429688, 120.94383239746,162.29713439941,5579.5678710938, progress, "Linear" ); setCameraMatrix (x, y, z, 116.48139190674, 156.49519348145, 5579.0087890625) end) Link to comment
Moderators IIYAMA Posted March 14, 2013 Author Moderators Share Posted March 14, 2013 woow thanks I was thinking about: local distance = BeginX - endX local distance_per_frame = distance /framecount x = BeginX + distance_per_frame But interpolateBetween is much better :3 Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 No problem. This is useful not only for 3D animations but also for 2D. You can move windows using the same function as well as resize them. For example a window popping up from outside of the screen or resize and pop up (eg. like in Windows 7). You can use different easing types for different animation styles. Good luck. Link to comment
Moderators IIYAMA Posted March 14, 2013 Author Moderators Share Posted March 14, 2013 btw: What is the best and lagg free way to check when the camera reached it's point? Link to comment
50p Posted March 14, 2013 Share Posted March 14, 2013 Once the "progress" will be >1 then the camera reached the destination so just add "else" to the "if" statement and then stop the camera movement (removeEventHandler + setCameraTarget to bring it back to player). You can also add new event and use trigger(Server)Event so that other scripts can use that event for their own purposes. I like using custom events. Link to comment
Moderators IIYAMA Posted March 14, 2013 Author Moderators Share Posted March 14, 2013 aha, It works very well, I made what I wanted to make. I send you my script maybe it inspires you. (just the cam) 1 Link to comment
ZkillCatIV Posted February 14, 2017 Share Posted February 14, 2017 (edited) Thank you so much this post helped me 100% P.S 50p you are awesome dude Edited February 14, 2017 by ZkillCatIV 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