Description: m-FOV is a realistic field of view system developed for FiveM, designed to enhance the roleplay experience.
This script adjusts character visibility based on the player’s perspective, reducing the opacity of characters outside the field of view. This ensures that players can only clearly see characters within their direct line of sight, making in-game awareness more immersive and realistic.
Features:
Realistic Field of View: NPCs and players outside the character’s vision become less visible.
Optimized Performance: FPS-friendly with minimal impact on server performance.
Fully Customizable: Opacity settings and interaction range can be configured.
Will this later include some stuff for like first-person so better field of view for first person shooting etc also for like vehicles like better FOV for that along with maybe including away for blind spots being things as a person that likes to drive in first person that would be really useful and to have a script that includes something like this along with the other features I mentioned I could see this script getting used a lot within the fiveM roleplay community
local config = {
viewAngle = 50,
alpha = 100
}
local function ChangeEntityAlpha(entity, alpha)
local entityAlpha = GetEntityAlpha(entity)
if entityAlpha == 0 then return end
if entityAlpha == alpha then return end
SetEntityAlpha(entity, alpha)
end
local function CanSeeEntity(direction, playerForwardVector)
return (direction.x * playerForwardVector.x + direction.y * playerForwardVector.y) < math.cos(math.rad(config.viewAngle))
end
local baseViewAngle = config.viewAngle
local maxViewAngle = baseViewAngle + 30
local minViewAngle = baseViewAngle - 10
CreateThread(function()
while true do
local playerPed = PlayerPedId()
local playerPos = GetEntityCoords(playerPed)
local playerForwardVector = GetEntityForwardVector(playerPed)
local playerVelocity = GetEntityVelocity(playerPed)
local speed = #vector3(playerVelocity.x, playerVelocity.y, 0.0)
local currentViewAngle = 0
if speed > 0 then
local speedFactor = math.min(speed / 7.0, 1.0)
currentViewAngle = minViewAngle + (maxViewAngle - minViewAngle) * speedFactor
else
currentViewAngle = minViewAngle
end
config.viewAngle = currentViewAngle
local peds = GetGamePool('CPed')
for _, ped in ipairs(peds) do
if ped ~= playerPed then
local pedPos = GetEntityCoords(ped)
local direction = pedPos - playerPos
local canSee = CanSeeEntity(direction, playerForwardVector)
ChangeEntityAlpha(ped, canSee and config.alpha or 255)
end
end
local vehicles = GetGamePool('CVehicle')
for _, vehicle in ipairs(vehicles) do
local vehiclePos = GetEntityCoords(vehicle)
local direction = vehiclePos - playerPos
local canSee = CanSeeEntity(direction, playerForwardVector)
ChangeEntityAlpha(vehicle, canSee and config.alpha or 255)
end
Wait(100)
end
end)