2kristof2 Posted March 23, 2016 Share Posted March 23, 2016 Hi, I used function setVehicleGravity which changes camera view. I'm trying to set the camera back to default settings. I'm sure it's not so easy to do. Maybe someone know where can I find default camera script or how to do that (any tips?) Arezu already solved the problem in magnet script but I can't find any link to check it out ( )If such script isn't public I'd be grateful for any advices regards, 2kristof2 Link to comment
arezu Posted March 24, 2016 Share Posted March 24, 2016 I used setVehicleGravity(vehicle, 0, 0, 0) and then used setElementVelocity on the vehicle in that script instead to simulate gravity, since setElementVelocity doesn't affect the camera in the same way as setVehicleGravity. Link to comment
2kristof2 Posted March 24, 2016 Author Share Posted March 24, 2016 Oh I tried it before but didn't change vehicle's gravity, it works now! Thanks Arezu Link to comment
2kristof2 Posted March 24, 2016 Author Share Posted March 24, 2016 Okay.. It almost works. I did wrong calculation with vx,vy,vz I guess.. because sometimes I drive unnaturally (too fast or too slow it depends in which direction I drive). (25th line) --Script Made By Bulldog~ -- local start = createMarker(3300, -1781.23632, 50.5, "corona" , 5, 0, 255, 255, 255) local stop = createMarker(55, 55, 55, "corona" , 5, 0, 0, 0, 0) local localPlayer = getLocalPlayer() local screenWidth, screenHeight = guiGetScreenSize() function addGravityFinder(veh) addEventHandler("onClientRender", root, magnetWheels) setElementHealth(veh, 1000000) end local power = 0.02 -- magnet's power function removeGravityFinder(veh) removeEventHandler("onClientRender", root, magnetWheels) end function magnetWheels() local veh = getPedOccupiedVehicle(localPlayer) local x,y,z = getElementPosition(veh) local vx,vy,vz = getElementVelocity(veh) local underx,undery,underz = getPositionUnderTheElement(veh) setVehicleGravity(veh, 0, 0, 0) setElementVelocity(veh, (underx - x)*power+vx, (undery - y)*power+vy, (underz - z)*power+vz) end function getPositionUnderTheElement(element) local matrix = getElementMatrix(element) local offX = 0 - 1 * matrix[3][1] + matrix[4][1] local offY = 0 - 1 * matrix[3][2] + matrix[4][2] local offZ = 0 - 1 * matrix[3][3] + matrix[4][3] return offX,offY,offZ end function stopMagnets(var) if var then removeEventHandler("onClientPlayerVehicleEnter", localPlayer, addGravityFinder) removeEventHandler("onClientPlayerVehicleExit", localPlayer, removeGravityFinder) removeEventHandler("onClientRender", root, magnetWheels) local veh = getPedOccupiedVehicle(localPlayer) if veh then setVehicleGravity(veh, 0, 0, -1) end else addEventHandler("onClientPlayerVehicleEnter", localPlayer, addGravityFinder) addEventHandler("onClientPlayerVehicleExit", localPlayer, removeGravityFinder) addEventHandler("onClientRender", root, magnetWheels) end end function magnetMarker(player) if player~=localPlayer then return end if source==start or source==start then stopMagnets(false) elseif source==stop or source==stop then stopMagnets(true) end end addEventHandler("onClientMarkerHit", resourceRoot, magnetMarker) Link to comment
arezu Posted March 24, 2016 Share Posted March 24, 2016 I'm not noticing anything like that in your script, or do you mean it's slow when you are turning? I think that is because your gravity is too strong. Btw, you should use onClientPreRender instead of onClientRender for the gravity and then multiply the gravity power with the 'timeSlice' parameter you get from onClientPreRender. If you dont multiply by the time slice, then the gravity will be very different depending on your fps. Link to comment
2kristof2 Posted March 24, 2016 Author Share Posted March 24, 2016 You are right, I will edit it. And I meant that the acceleration of a vehicle seems to be unstable. (it's not really annoying since I want to use the script only on few parts of a map but still I'd like to fix that) EDIT: nvm I don't really need help already, besides Arezu left mta sadly.. 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