Actor support

This commit is contained in:
2024-02-21 13:23:23 -05:00
parent ff16d8ceb3
commit e5f1a546b1
21 changed files with 284 additions and 73 deletions

View File

@@ -3,6 +3,9 @@ local CrosshairModule = {
}
CrosshairModule.__index = CrosshairModule
local Storage = game:GetService("ReplicatedStorage")
local Easings = require(Storage:WaitForChild("AlgebraEasings"))
--Use a custom crosshair so we can do effects to it
type rbxassetid = string
@@ -17,15 +20,24 @@ function CrosshairModule.constructor(PlayerGui: PlayerGui)
end
function CrosshairModule:Enable()
self.Screen.Enabled = true
(self.Screen :: ScreenGui).Enabled = true
end
function CrosshairModule:Disable()
self.Screen.Enabled = false
(self.Screen :: ScreenGui).Enabled = false
end
function CrosshairModule:Change(ID: rbxassetid)
self.Icon.Image = ID or CrosshairModule.Icon
(self.Icon :: ImageLabel).Image = ID or CrosshairModule.Icon
end
function CrosshairModule:Jump(RootVelocity: Vector3)
local X, Y = RootVelocity.X, RootVelocity.Y;
(self.Icon :: ImageLabel).Position = UDim2.fromScale(
Y>1 and Easings.Linear(.5,.5+(X/1000),.3) or .5,
math.clamp(.4, .5-(-Y/1000), .6)
)
end
return CrosshairModule

View File

@@ -0,0 +1,34 @@
local HealthModule = {}
HealthModule.__index = HealthModule
function HealthModule.constructor(PlayerGui: PlayerGui)
local HealthGui = PlayerGui:WaitForChild("Health")
local Amount = HealthGui:WaitForChild("Amount")
return setmetatable({
HealthGui = HealthGui,
Amount = Amount
}, HealthGui)
end
function HealthModule:Enable()
HealthModule.Enabled = true
end
function HealthModule:Disable()
HealthModule.Enabled = false
end
function HealthModule:DisplayHealth(Amount: number)
self.Amount.Text = tostring(Amount)
if Amount <= 40 then
self.Amount.TextColor3 = Color3.fromRGB(255,238,0)
elseif Amount <= 20 then
self.Amount.TextColor3 = Color3.fromRGB(255,0,38)
else
self.Amount.TextColor3 = Color3.new(1,1,1)
end
end
return HealthModule

View File

@@ -1,11 +1,13 @@
local UI = script:WaitForChild("UI")
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
local VignetteSettings = require(UI:WaitForChild("Vignette"))
local HealthSettings = require(UI:WaitForChild("Health"))
local CoreGuis = require(script:WaitForChild("CoreGuis"))
local Mouse = require(script:WaitForChild("Mouse"))
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService") :: RunService
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
@@ -33,7 +35,7 @@ local Crosshair = CrosshairSettings.constructor(PlayerGui)
--Keybinds
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor()
local CameraBindMap = KeyBindsModule.constructor(false)
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomIn(Vignette, Crosshair)
@@ -43,9 +45,21 @@ local function CameraBinds()
end)
end
local function Crosshair3DEffect()
local RootVelocity = Instance.new("BindableEvent") :: BindableEvent
RootVelocity.Name = "RootVelocity"
RootVelocity.Parent = ClientStorage
RootVelocity.Event:Connect(function(RootVelocity: Vector3)
Crosshair:Jump(RootVelocity)
end)
end
CoreGuis:Off()
Camera:FirstPerson()
Mouse:DisablePointer()
Crosshair:Enable()
HealthSettings:Enable()
CameraBinds()
CameraBinds()
Crosshair3DEffect()