Jump to content

xxMANxx

Members
  • Posts

    24
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

xxMANxx's Achievements

Civilian

Civilian (7/54)

1

Reputation

  1. setPedLookAt and setPedAimTarget doest not working on players in vehicle green line - a gaze direction of player are there any ways to solve this?
  2. how to find out that the rectangles collide knowing the coordinates of all their vertices?
  3. how to know for example that there is water within a radius of 20 meters from the player?
  4. how to know that the player is under water? (dived) ye i know that z < 0 it's under water line, but if wave heights? or dam zone (tierra robada), there's a different water line
  5. thanks for help, I'll try to understand
  6. when turn the camera, it turns as if roll = 0
  7. I am doing First Person Perspective. When camera roll = 0, everything works fine. But if the camera roll is not equal to 0, then the camera also rotates as if the camera roll is 0. principle: addEventHandler ('onClientCursorMove',root, freecamMouse) function freecamMouse (cX,cY,aX,aY) -- how far have we moved the mouse from the screen center? local width, height = guiGetScreenSize() aX = aX - width / 2 aY = aY - height / 2 rotX = rotX + aX * mouseSensitivity * 0.01745 rotY = rotY - aY * mouseSensitivity * 0.01745 end addEventHandler ('onClientPreRender', root, updateCamera) function updateCamera() local camPosXr, camPosYr, camPosZr = getPedBonePosition (localPlayer, 6) local camPosXl, camPosYl, camPosZl = getPedBonePosition (localPlayer, 7) local camPosX, camPosY, camPosZ = (camPosXr + camPosXl) / 2, (camPosYr + camPosYl) / 2, (camPosZr + camPosZl) / 2 -- note the vehicle rotation if inVehicle then local rx,ry,rz = getElementRotation(getPedOccupiedVehicle(localPlayer)) roll = -ry if rx > 90 and rx < 270 then roll = ry - 180 end if not wasInVehicle then rotX = rotX + math.rad(rz) if rotY > -PI/15 then rotY = -PI/15 end end cameraAngleX = rotX - math.rad(rz) cameraAngleY = rotY + math.rad(rx) else roll = 0 cameraAngleX = rotX cameraAngleY = rotY end --Taken from the freecam resource made by eAi -- work out an angle in radians based on the number of pixels the cursor has moved (ever) local freeModeAngleZ = math.sin(cameraAngleY) local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX) local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX) -- calculate a target based on the current position and an offset based on the angle local camTargetX = camPosX + freeModeAngleX * 100 local camTargetY = camPosY + freeModeAngleY * 100 local camTargetZ = camPosZ + freeModeAngleZ * 100 -- Work out the distance between the target and the camera (should be 100 units) local camAngleX = camPosX - camTargetX local camAngleY = camPosY - camTargetY local camAngleZ = 0 -- we ignore this otherwise our vertical angle affects how fast you can strafe -- Calulcate the length of the vector local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ) -- Normalize the vector, ignoring the Z axis, as the camera is stuck to the XY plane (it can't roll) local camNormalizedAngleX = camAngleX / angleLength local camNormalizedAngleY = camAngleY / angleLength local camNormalizedAngleZ = 0 -- We use this as our rotation vector local normalAngleX = 0 local normalAngleY = 0 local normalAngleZ = 1 -- Perform a cross product with the rotation vector and the normalzied angle local normalX = (camNormalizedAngleY * normalAngleZ - camNormalizedAngleZ * normalAngleY) local normalY = (camNormalizedAngleZ * normalAngleX - camNormalizedAngleX * normalAngleZ) local normalZ = (camNormalizedAngleX * normalAngleY - camNormalizedAngleY * normalAngleX) -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame) camTargetX = camPosX + freeModeAngleX * 100 camTargetY = camPosY + freeModeAngleY * 100 camTargetZ = camPosZ + freeModeAngleZ * 100 -- Set the new camera position and target setCameraMatrix (camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ, roll, fov) end I think need something like that. but I don’t know how to do this, because the parameter "roll" in setCameraMatrix rotates only “visually” and not the coordinate system
  8. you helped me again thanks
  9. How to fix it? f everything is fine here
  10. xxMANxx

    Need help

    it works thank you so much
  11. xxMANxx

    Need help

    I am doing first-person view and want to limit the camera so that it does not rotate 360 degrees. if cameraRotation > playerRotation + 90 then cameraRotation = playerRotation + 90 elseif cameraRotation < playerRotation - 90 then cameraRotation = playerRotation - 90 end Everything works until playerRotation becomes 350, and the cameraRotation >360 and becomes 0, then the condition works, but it should not work.
×
×
  • Create New...