-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcam.lua
More file actions
100 lines (65 loc) · 2.37 KB
/
cam.lua
File metadata and controls
100 lines (65 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
charCam = CreateCam('DEFAULT_SCRIPTED_CAMERA', true)
--SetCamActive(charCam, true)
-- Blend in
--RenderScriptCams(true, true, 0, true, true)
--ShakeCam(charCam, "JOLT_SHAKE", 2.0)
local shakeAmount = 0.0
local bIsShaking = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
SetGameplayCamShakeAmplitude(shakeAmount)
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(20)
if not bIsShaking and shakeAmount > 2.0 then
print("start shaking!?")
bIsShaking = true
end
end
end)
local shakeMinSpeed = 2.0
local shakeMaxSpeed = 6.0
local maxShakeAmount = 0.5
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
local vel = GetEntityVelocity(GetPlayerPed(-1))
local speed = math.abs(vel.x) + math.abs(vel.y) + math.abs(vel.z)
local percentageMax = shakeMaxSpeed - shakeMinSpeed
local speedPercentage = speed/percentageMax*100
--print(speedPercentage)
if speed <= shakeMinSpeed then
shakeAmount = 0.0
bIsShaking = false
else
shakeAmount = (maxShakeAmount/100*speedPercentage) + 0.0
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
--ShakeGameplayCam(‘SMALL_EXPLOSION_SHAKE’, 0.18)
--SetGameplayCamShakeAmplitude(5.0)
local camCoords = GetGameplayCamCoord()
local camRot = GetGameplayCamRot(2)
local camHeading = GetGameplayCamRelativeHeading()
--print(camHeading)
--local playerVector = GetEntityCoords(GetPlayerPed(-1))
--local _, forwardVector, _, position = GetEntityMatrix(vehicle)
local forwardVector, rightVector, upVector, position = GetEntityMatrix(GetPlayerPed(-1))
local playerVector = (upVector * 0.5) + (rightVector * 0.5) + position
local midpoint = (playerVector + camCoords) / 2
local dist = #(position - midpoint)
-- -- Use Z
SetCamCoord(charCam, midpoint.x, midpoint.y, midpoint.z)
SetCamRot(charCam, camRot.x, camRot.y, camRot.z, 2)
SetCamFov(charCam, 60.0)
--SetGameplayCamShakeAmplitude(1.0)
--SetFollowPedCamThisUpdate(charCam, 0)
--SetFollowPedCamViewMode(1)
end
end)