Xierra Posted April 10, 2010 Share Posted April 10, 2010 Hi guys! I have a question. Do you know most of the NFS games? What I mean here is that when you steer left or right (x) and not up and down, the camera will always follows it. On GTA SA, it doesn't. I already think this is possible in MTA, so I got to figure it out how... I dunno how to start. Can you guys tell me how? Link to comment
karlis Posted April 10, 2010 Share Posted April 10, 2010 (edited) some simple trigonometry, and getting position of vehicle, and zrotation --clientside local enabled=false function getPointFromDistanceRotation(x, y, dist, angle) --credits to robhol local a = math.rad(90 - angle) local dx = math.cos(a) * dist local dy = math.sin(a) * dist return x+dx, y+dy end addCommandHandler("nfscam",function() if enabled then removeEventHandler("onClientRender",getRootElement(),rendercam) else addEventHandler("onClientRender",getRootElement(),rendercam) end enabled=not enabled end) function rendercam() local x,y,z=getElementPosition(getPedOccupiedVehicle(getLocalPlayer())) local _,_,rotz=getElementRotation(getPedOccupiedVehicle(getLocalPlayer())) local x2,y2=getPointFromDistanceRotation(x, y, 15, rotz+180%360) setCameraMatrix(x,y,z,x2,y2,z+6) end Edited April 11, 2010 by Guest Link to comment
Xierra Posted April 11, 2010 Author Share Posted April 11, 2010 Ah, You put the camera on the cockpit! Also, I don't want camera like that. Something that doesn't shake and doesn't remove the parts of the HUD. Link to comment
Xierra Posted April 11, 2010 Author Share Posted April 11, 2010 No answers? You know, the camera is like in Magnetwheels resource, but what I want is only follows right and left not up and down. Link to comment
karlis Posted April 11, 2010 Share Posted April 11, 2010 hud is not removed, and thats also not cockpit, and add some math.round for camera position for camera shake terminating Link to comment
Dark Dragon Posted April 11, 2010 Share Posted April 11, 2010 i think this will give a similar effect: -- client addEventHandler("onClientPreRender",getRootElement(), function() setCameraTarget(getLocalPlayer()) end ) Link to comment
karlis Posted April 11, 2010 Share Posted April 11, 2010 Ye, very nice would be to check mouse and dont set target if mouse moving Link to comment
Xierra Posted April 12, 2010 Author Share Posted April 12, 2010 Yeah, I want that. Moving the camera by mouse means making the target to be removed, then after 3 seconds of letting it go, target it back again. And dragon, where should I put that? Link to comment
Jason_Gregory Posted April 12, 2010 Share Posted April 12, 2010 In your Clientside Script, onClientRender is a Clientside Function only... Link to comment
karlis Posted April 12, 2010 Share Posted April 12, 2010 try this, heres included that 3sec timer local lastMouseTick=0 local enabled=false function mousemove() lastMouseTick=getTickCount() end function targetcam() if getTickCount()-3000>lastMouseTick then setCameraTarget(getLocalPlayer()) end end function enablecam() if enabled then removeEventHandler("onClientMouseMove",getRootElement(),mosuemove) removeEventHandler("onClientPreRender",getRootElement(),targetcam) else addEventHandler("onClientMouseMove",getRootElement(),mosuemove) addEventHandler("onClientPreRender",getRootElement(),targetcam) end enabled=not enabled end addCommandHandler("nfscam",enablecam) bindKey("N","up","nfscam") note:im not sure do i need use onClientMouseMove or onClientCursorMove Link to comment
Xierra Posted April 12, 2010 Author Share Posted April 12, 2010 I got bad arguments on line 16 & 19 if I execute a command. What about this, if the vehicle is only facing down, the camera follows it. Link to comment
karlis Posted April 12, 2010 Share Posted April 12, 2010 change mosuemove to mousemove 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