local target_yaw = 0
local current_yaw = nil
local transition_speed = 0.1
local randomize_interval = 2.0
local last_randomize_time = os.clock()
local function calculateYaw(direction_vector)
return math.atan2(direction_vector.y, -direction_vector.x)
end
local function add_random_offset()
local random_offset = (math.random() - 0.5) * 0.1 -- меняем если надо
current_yaw = current_yaw + random_offset
end
function set_camera_direction(point)
local c_pos_x, c_pos_y, c_pos_z = getActiveCameraCoordinates()
local current_time = os.clock()
local direction_vector = {
x = point[1] - c_pos_x,
y = point[2] - c_pos_y
}
target_yaw = calculateYaw(direction_vector)
if current_yaw == nil then
current_yaw = math.rad(getCharHeading(PLAYER_PED))
end
if (current_time - last_randomize_time) >= randomize_interval then
add_random_offset()
last_randomize_time = current_time
end
current_yaw = current_yaw + (target_yaw - current_yaw) * transition_speed
setCameraPositionUnfixed(0.0, -current_yaw)
end