Advertisement

Help with lua script

Started by March 03, 2019 01:45 AM
0 comments, last by mtrm92 5 years, 8 months ago

Hallo fellas, iam using gameguru, i want to create a bullet impact effect on the player, a little camera shake like here on this video minute 2:24

heres the script but it doesnt work

 


--how long to shake camera for
local duration = 500

--how far down camera can move in 1 update
local vertical_low = -5
--how far up camera can move in 1 update
local vertical_high = 5
--how far left camera can move in 1 update
local horizontal_low = -5
--how far right camera can move in 1 update
local horizontal_high = 5
local playerHealth = g_PlayerHealth

local x = 0
local y = 0
local state = ""

function shake_camera_init(e)
CollisionOff(e)
Hide(e)
end

function shake_camera_main(e)

if g_PlayerHealth < playerHealth then
  state = "shake"
  playerHealth = g_PlayerHealth
end

if state == "shake" then
if x < duration then
SetPosition(e,g_PlayerPosX,g_Entity[e]['y']-g_PlayerPosY+600,g_PlayerPosZ)
SetRotation(e,g_PlayerAngX-math.random(vertical_low,vertical_high),g_PlayerAngY+math.random(horizontal_low,horizontal_high),g_PlayerAngZ)
if y >= 5 then
TransportToIfUsed(e)
y = 0
else
y = y + 1 
end
x = x + 1 
else
x = 0
y = 0
state = ""
end
end

end --main

function shake_camera_exit(e)

end

generaly it was a script to shake the camera by pressing a key, i wanna change it to shake the camera triggered by getting hurted, heres the original script that works


--how long to shake camera for
local duration = 500
 
--how far down camera can move in 1 update
local vertical_low = -5
--how far up camera can move in 1 update
local vertical_high = 5
--how far left camera can move in 1 update
local horizontal_low = -5
--how far right camera can move in 1 update
local horizontal_high = 5
 
 
local x = 0
local y = 0
local state = ""
 
function shake_camera_init(e)
CollisionOff(e)
Hide(e)
end
 
function shake_camera_main(e)
 
if GetInKey() == "e" then
state = "shake"
end
 
if state == "shake" then
if x < duration then
SetPosition(e,g_PlayerPosX,g_Entity[e]['y']-g_PlayerPosY+600,g_PlayerPosZ)
SetRotation(e,g_PlayerAngX-math.random(vertical_low,vertical_high),g_PlayerAngY+math.random(horizontal_low,horizontal_high),g_PlayerAngZ)
if y >= 5 then
TransportToIfUsed(e)
y = 0
else
y = y + 1 
end
x = x + 1 
else
x = 0
y = 0
state = ""
end
end
 
end --main
 
function shake_camera_exit(e)
 
end

Can anyone help me with that?

Thank u

This topic is closed to new replies.

Advertisement