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 Camera.VignetteEnabled then
|
||||||
if Vignette then
|
if Vignette then
|
||||||
Vignette.VignetteSettings.Enabled = true
|
Vignette.Screen.Enabled = true
|
||||||
|
|
||||||
VignetteTween:Start(Vignette.VignetteSettings.VignetteIcon, {
|
VignetteTween:Start(Vignette.Icon, {
|
||||||
ImageTransparency = 0
|
ImageTransparency = 0
|
||||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||||
else
|
else
|
||||||
warn("Camera: ", debug.traceback())
|
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Camera.CrosshairEffect then
|
if Camera.CrosshairEffect then
|
||||||
if Crosshair then
|
if Crosshair then
|
||||||
|
VignetteTween:Start(Crosshair.Icon, {
|
||||||
|
ImageTransparency = .9
|
||||||
|
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||||
else
|
else
|
||||||
warn("Camera: ", debug.traceback())
|
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -72,21 +74,23 @@ function Camera:ZoomOut(Vignette: Vignette?, Crosshair: Crosshair?)
|
|||||||
|
|
||||||
if Camera.VignetteEnabled then
|
if Camera.VignetteEnabled then
|
||||||
if Vignette then
|
if Vignette then
|
||||||
Vignette.VignetteSettings.Enabled = true
|
Vignette.Screen.Enabled = true
|
||||||
|
|
||||||
VignetteTween:Start(Vignette.VignetteSettings.VignetteIcon, {
|
VignetteTween:Start(Vignette.Icon, {
|
||||||
ImageTransparency = 1
|
ImageTransparency = 1
|
||||||
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
|
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
|
||||||
else
|
else
|
||||||
warn("Camera: ", debug.traceback())
|
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Camera.CrosshairEffect then
|
if Camera.CrosshairEffect then
|
||||||
if Crosshair then
|
if Crosshair then
|
||||||
|
VignetteTween:Start(Crosshair.Icon, {
|
||||||
|
ImageTransparency = 0
|
||||||
|
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||||
else
|
else
|
||||||
warn("Camera: ", debug.traceback())
|
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,25 +7,25 @@ CrosshairModule.__index = CrosshairModule
|
|||||||
type rbxassetid = string
|
type rbxassetid = string
|
||||||
|
|
||||||
function CrosshairModule.constructor(PlayerGui: PlayerGui)
|
function CrosshairModule.constructor(PlayerGui: PlayerGui)
|
||||||
local Crosshair = PlayerGui:WaitForChild("Crosshair")
|
local Screen = PlayerGui:WaitForChild("Crosshair")
|
||||||
local CrosshairIcon = Crosshair:WaitForChild("ImageLabel")
|
local Icon = Screen:WaitForChild("ImageLabel")
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Crosshair = Crosshair,
|
Screen = Screen,
|
||||||
CrosshairIcon = CrosshairIcon
|
Icon = Icon
|
||||||
}, CrosshairModule)
|
}, CrosshairModule)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CrosshairModule:Enable()
|
function CrosshairModule:Enable()
|
||||||
self.Crosshair.Enabled = true
|
self.Screen.Enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function CrosshairModule:Disable()
|
function CrosshairModule:Disable()
|
||||||
self.Crosshair.Enabled = false
|
self.Screen.Enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function CrosshairModule:Change(ID: rbxassetid)
|
function CrosshairModule:Change(ID: rbxassetid)
|
||||||
self.CrosshairIcon.Image = ID or CrosshairModule.Icon
|
self.Icon.Image = ID or CrosshairModule.Icon
|
||||||
end
|
end
|
||||||
|
|
||||||
return CrosshairModule
|
return CrosshairModule
|
||||||
@@ -4,23 +4,23 @@ local VignetteModule = {
|
|||||||
VignetteModule.__index = VignetteModule
|
VignetteModule.__index = VignetteModule
|
||||||
|
|
||||||
function VignetteModule.constructor(PlayerGui: PlayerGui)
|
function VignetteModule.constructor(PlayerGui: PlayerGui)
|
||||||
local Vignette = PlayerGui:WaitForChild("Vignette")
|
local Screen = PlayerGui:WaitForChild("Vignette")
|
||||||
local VignetteIcon = Vignette:WaitForChild("ImageLabel")
|
local Icon = Screen:WaitForChild("ImageLabel")
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Vignette = Vignette,
|
Screen = Screen,
|
||||||
VignetteIcon = VignetteIcon
|
Icon = Icon
|
||||||
}, VignetteModule)
|
}, VignetteModule)
|
||||||
end
|
end
|
||||||
|
|
||||||
function VignetteModule:Enable()
|
function VignetteModule:Enable()
|
||||||
VignetteModule.Enabled = true
|
VignetteModule.Enabled = true
|
||||||
self.Vignette.Enabled = true
|
self.Screen.Enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function VignetteModule:Disable()
|
function VignetteModule:Disable()
|
||||||
VignetteModule.Enabled = false
|
VignetteModule.Enabled = false
|
||||||
self.Vignette.Enabled = false
|
self.Screen.Enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
return VignetteModule
|
return VignetteModule
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
local UI = script:WaitForChild("UI")
|
local UI = script:WaitForChild("UI")
|
||||||
local Crosshair = require(UI:WaitForChild("Crosshair"))
|
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
||||||
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
||||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||||
local Mouse = require(script:WaitForChild("Mouse"))
|
local Mouse = require(script:WaitForChild("Mouse"))
|
||||||
local CameraSettings = require(script:WaitForChild("Camera"))
|
local CameraSettings = require(script:WaitForChild("Camera"))
|
||||||
|
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
@@ -22,23 +22,23 @@ until CurrentCamera
|
|||||||
|
|
||||||
local Vignette = VignetteSettings.constructor(PlayerGui)
|
local Vignette = VignetteSettings.constructor(PlayerGui)
|
||||||
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
||||||
local CrosshairObject = Crosshair.constructor(PlayerGui)
|
local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
||||||
|
|
||||||
--Keybinds
|
--Keybinds
|
||||||
local function CameraBinds()
|
local function CameraBinds()
|
||||||
local CameraBindMap = KeyBindsModule.constructor()
|
local CameraBindMap = KeyBindsModule.constructor()
|
||||||
|
|
||||||
CameraBindMap:AddInputBegan(Enum.KeyCode.C, function()
|
CameraBindMap:AddInputBegan(Enum.KeyCode.C, function()
|
||||||
Camera:ZoomIn(Vignette)
|
Camera:ZoomIn(Vignette, Crosshair)
|
||||||
end)
|
end)
|
||||||
CameraBindMap:AddInputEnded(Enum.KeyCode.C, function()
|
CameraBindMap:AddInputEnded(Enum.KeyCode.C, function()
|
||||||
Camera:ZoomOut(Vignette)
|
Camera:ZoomOut(Vignette, Crosshair)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
CoreGuis:off()
|
CoreGuis:off()
|
||||||
Mouse:DisablePointer()
|
Mouse:DisablePointer()
|
||||||
Camera:FirstPerson()
|
Camera:FirstPerson()
|
||||||
CrosshairObject:Enable()
|
Crosshair:Enable()
|
||||||
|
|
||||||
CameraBinds()
|
CameraBinds()
|
||||||
Reference in New Issue
Block a user