mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Camera zoom in effect on the crosshair
This commit is contained in:
@@ -46,21 +46,23 @@ function Camera:ZoomIn(Vignette: Vignette?, Crosshair: Crosshair?)
|
||||
|
||||
if Camera.VignetteEnabled then
|
||||
if Vignette then
|
||||
Vignette.VignetteSettings.Enabled = true
|
||||
Vignette.Screen.Enabled = true
|
||||
|
||||
VignetteTween:Start(Vignette.VignetteSettings.VignetteIcon, {
|
||||
VignetteTween:Start(Vignette.Icon, {
|
||||
ImageTransparency = 0
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: ", debug.traceback())
|
||||
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
if Camera.CrosshairEffect then
|
||||
if Crosshair then
|
||||
|
||||
VignetteTween:Start(Crosshair.Icon, {
|
||||
ImageTransparency = .9
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: ", debug.traceback())
|
||||
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -72,21 +74,23 @@ function Camera:ZoomOut(Vignette: Vignette?, Crosshair: Crosshair?)
|
||||
|
||||
if Camera.VignetteEnabled then
|
||||
if Vignette then
|
||||
Vignette.VignetteSettings.Enabled = true
|
||||
Vignette.Screen.Enabled = true
|
||||
|
||||
VignetteTween:Start(Vignette.VignetteSettings.VignetteIcon, {
|
||||
VignetteTween:Start(Vignette.Icon, {
|
||||
ImageTransparency = 1
|
||||
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: ", debug.traceback())
|
||||
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
if Camera.CrosshairEffect then
|
||||
if Crosshair then
|
||||
|
||||
VignetteTween:Start(Crosshair.Icon, {
|
||||
ImageTransparency = 0
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: ", debug.traceback())
|
||||
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,25 +7,25 @@ CrosshairModule.__index = CrosshairModule
|
||||
type rbxassetid = string
|
||||
|
||||
function CrosshairModule.constructor(PlayerGui: PlayerGui)
|
||||
local Crosshair = PlayerGui:WaitForChild("Crosshair")
|
||||
local CrosshairIcon = Crosshair:WaitForChild("ImageLabel")
|
||||
local Screen = PlayerGui:WaitForChild("Crosshair")
|
||||
local Icon = Screen:WaitForChild("ImageLabel")
|
||||
|
||||
return setmetatable({
|
||||
Crosshair = Crosshair,
|
||||
CrosshairIcon = CrosshairIcon
|
||||
Screen = Screen,
|
||||
Icon = Icon
|
||||
}, CrosshairModule)
|
||||
end
|
||||
|
||||
function CrosshairModule:Enable()
|
||||
self.Crosshair.Enabled = true
|
||||
self.Screen.Enabled = true
|
||||
end
|
||||
|
||||
function CrosshairModule:Disable()
|
||||
self.Crosshair.Enabled = false
|
||||
self.Screen.Enabled = false
|
||||
end
|
||||
|
||||
function CrosshairModule:Change(ID: rbxassetid)
|
||||
self.CrosshairIcon.Image = ID or CrosshairModule.Icon
|
||||
self.Icon.Image = ID or CrosshairModule.Icon
|
||||
end
|
||||
|
||||
return CrosshairModule
|
||||
@@ -4,23 +4,23 @@ local VignetteModule = {
|
||||
VignetteModule.__index = VignetteModule
|
||||
|
||||
function VignetteModule.constructor(PlayerGui: PlayerGui)
|
||||
local Vignette = PlayerGui:WaitForChild("Vignette")
|
||||
local VignetteIcon = Vignette:WaitForChild("ImageLabel")
|
||||
local Screen = PlayerGui:WaitForChild("Vignette")
|
||||
local Icon = Screen:WaitForChild("ImageLabel")
|
||||
|
||||
return setmetatable({
|
||||
Vignette = Vignette,
|
||||
VignetteIcon = VignetteIcon
|
||||
Screen = Screen,
|
||||
Icon = Icon
|
||||
}, VignetteModule)
|
||||
end
|
||||
|
||||
function VignetteModule:Enable()
|
||||
VignetteModule.Enabled = true
|
||||
self.Vignette.Enabled = true
|
||||
self.Screen.Enabled = true
|
||||
end
|
||||
|
||||
function VignetteModule:Disable()
|
||||
VignetteModule.Enabled = false
|
||||
self.Vignette.Enabled = false
|
||||
self.Screen.Enabled = false
|
||||
end
|
||||
|
||||
return VignetteModule
|
||||
@@ -1,5 +1,5 @@
|
||||
local UI = script:WaitForChild("UI")
|
||||
local Crosshair = require(UI:WaitForChild("Crosshair"))
|
||||
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
||||
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||
local Mouse = require(script:WaitForChild("Mouse"))
|
||||
@@ -22,23 +22,23 @@ until CurrentCamera
|
||||
|
||||
local Vignette = VignetteSettings.constructor(PlayerGui)
|
||||
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
||||
local CrosshairObject = Crosshair.constructor(PlayerGui)
|
||||
local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
||||
|
||||
--Keybinds
|
||||
local function CameraBinds()
|
||||
local CameraBindMap = KeyBindsModule.constructor()
|
||||
|
||||
CameraBindMap:AddInputBegan(Enum.KeyCode.C, function()
|
||||
Camera:ZoomIn(Vignette)
|
||||
Camera:ZoomIn(Vignette, Crosshair)
|
||||
end)
|
||||
CameraBindMap:AddInputEnded(Enum.KeyCode.C, function()
|
||||
Camera:ZoomOut(Vignette)
|
||||
Camera:ZoomOut(Vignette, Crosshair)
|
||||
end)
|
||||
end
|
||||
|
||||
CoreGuis:off()
|
||||
Mouse:DisablePointer()
|
||||
Camera:FirstPerson()
|
||||
CrosshairObject:Enable()
|
||||
Crosshair:Enable()
|
||||
|
||||
CameraBinds()
|
||||
Reference in New Issue
Block a user