Jump to content

rubend10s

Members
  • Posts

    7
  • Joined

  • Last visited

rubend10s's Achievements

Newbie

Newbie (4/54)

1

Reputation

  1. I have a problem with the camera using setVehicleGravity and it has strange behaviors when the vehicle is rotated 90 or -90 degrees on the y axis and points to certain directions as in the video https://streamable.com/pfrbt The only solution I could think of is putting gravity with setElementVelocity so I avoid the camera, but the problem is that I have to make my own camera if I want to achieve an effect similar to setVehicleGravity and I don't know the mechanics that the default camera uses I found some interesting topics like these but still I can't imitate the effect of the default camera The most difficult thing is to imitate the effect of the camera when the vehicle turns, which is like a smooth interpolation, but I can't decipher the mechanics. I made several attempts using interpolation and depending on the velocity vector, but nothing seems to mimic it I also found someone who made a similar camera in gta vice city but I don't know how to see his code https://gtaforums.com/topic/896122-classic-axis-visual-camera-improvements/
  2. The problem is a bit difficult to explain. When I modify vehicle values that have to do with traction, these work very well when the vehicle is in "normal" gravity or check the "isVehicleOnGround" function to be more precise, the problem is when for example the vehicle is driving vertically (such as a wall) or inverted (effect of the magnet wheels script) the effects of traction or vehicle handling dont work. This only happens with traction, acceleration and maximum speed values for example work perfectly on any rotated surface Is there any way to mimic traction on vertical or inverted surfaces without having to use vehicle handling functions?
  3. oh that's a good way, I did something similar but I didn't write it down, I just looked at them haha I managed to approximate gravity quite a bit by changing the fps value with fps = 1000/50 it is not exactly the same but it approximates at least it's a good way to avoid the annoying camera
  4. How can I get to simulate default gravity? this is my code fps = 1000/36 -- 36 frames per 1000 miliseconds default value server gravity = 0.008 -- global gravity of the server function gravity_without_camera( timeSlice ) local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) local speedX, speedY, speedZ = getElementVelocity( vehicle ) local new_gravity = gravity * ( timeSlice / fps ) setElementVelocity ( vehicle, speedX, speedY, speedZ - new_gravity ) end function set_new_gravity() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if not toggleOff then removeEventHandler("onClientPreRender",getRootElement(),gravity_without_camera) outputChatBox ( "script disabled" ) setVehicleGravity( vehicle, 0, 0, -1 ) toggleOff = true else addEventHandler("onClientPreRender",getRootElement(),gravity_without_camera) outputChatBox ( "script enabled" ) setVehicleGravity( vehicle, 0, 0, 0 ) toggleOff = false end end bindKey ( "m","down", set_new_gravity) the new gravity is a little more powerful than the default gravity idk why
  5. I want to use this resource https://community.multitheftauto.com/index.php?p=resources&s=details&id=329 and detect when the vehicle is stepping on something isVehicleOnGround it doesn't work either because it doesn't detect for example when I'm driving in a building
  6. I think I did it, it looks good function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function arrow_u_function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local tx, ty, tz = getPositionFromElementOffset(vehicle,1,0,0) local avx, avy, avz = getElementAngularVelocity(vehicle) local vx,vy,vz = getElementPosition( vehicle ) setElementAngularVelocity ( vehicle, avx - 0.1 * (tx - vx), avy - 0.1 * (ty - vy), avz - 0.1 * (tz - vz) ) end function arrow_d_function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local tx, ty, tz = getPositionFromElementOffset(vehicle,1,0,0) local avx, avy, avz = getElementAngularVelocity(vehicle) local vx,vy,vz = getElementPosition( vehicle ) setElementAngularVelocity ( vehicle, avx + 0.1 * (tx - vx), avy + 0.1 * (ty - vy), avz + 0.1 * (tz - vz) ) end function arrow_l_function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local tx, ty, tz = getPositionFromElementOffset(vehicle,0,1,0) local avx, avy, avz = getElementAngularVelocity(vehicle) local vx,vy,vz = getElementPosition( vehicle ) setElementAngularVelocity ( vehicle, avx - 0.1 * (tx - vx), avy - 0.1 * (ty - vy), avz - 0.1 * (tz - vz) ) end function arrow_r_function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local tx, ty, tz = getPositionFromElementOffset(vehicle,0,1,0) local avx, avy, avz = getElementAngularVelocity(vehicle) local vx,vy,vz = getElementPosition( vehicle ) setElementAngularVelocity ( vehicle, avx + 0.1 * (tx - vx), avy + 0.1 * (ty - vy), avz + 0.1 * (tz - vz) ) end bindKey ( "arrow_u","down", arrow_u_function) bindKey ( "arrow_d","down", arrow_d_function) bindKey ( "arrow_l","down", arrow_l_function) bindKey ( "arrow_r","down", arrow_r_function)
  7. I was thinking of something like this to start function increaseRotationFunction() if getKeyState( "arrow_u" ) == true or getKeyState( "arrow_d" ) == true or getKeyState( "arrow_l" ) == true or getKeyState( "arrow_r" ) == true then local vehicle = getPedOccupiedVehicle(getLocalPlayer()) -- and i dont know end end addEventHandler("onClientRender",getRootElement(),increaseRotationFunction) and then use something like setElementAngularVelocity and getElementAngularVelocity I tried this but it didn't work too well function increaseRotationFunction() if getKeyState( "arrow_u" ) == true or getKeyState( "arrow_d" ) == true or getKeyState( "arrow_l" ) == true or getKeyState( "arrow_r" ) == true then local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local avx, avy, avz = getElementAngularVelocity(vehicle) setElementAngularVelocity ( vehicle, avx * 2, avy * 2, avz * 2 ) end end addEventHandler("onClientRender",getRootElement(),increaseRotationFunction)
×
×
  • Create New...