23
This commit is contained in:
1 parent
edb7f16cda
commit
1d667306da
2 files changed
+41
-27
No files matched your search
BIN
Binary file not shown.
@@ -7,20 +7,29 @@ local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScri
|
||||
local player = Players.LocalPlayer
|
||||
local playerGui = player:WaitForChild("PlayerGui")
|
||||
local arena = Modes.geometry(Modes.Procedural)
|
||||
type Arrow = {gui: BillboardGui, chevrons: {Model}, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number}
|
||||
type Arrow = {gui: Frame, chevrons: {Model}, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number}
|
||||
local arrows: {[BasePart]: Arrow} = {}
|
||||
local SIZE = 156
|
||||
local HEIGHT = 105
|
||||
local MAX_DISTANCE = 710
|
||||
local ANIMATION_RATE = 2 * math.pi / 4.5
|
||||
|
||||
local overlay = Instance.new("ScreenGui")
|
||||
overlay.Name = "ObjectiveArrows"
|
||||
overlay.ResetOnSpawn = false
|
||||
overlay.IgnoreGuiInset = true
|
||||
overlay.ScreenInsets = Enum.ScreenInsets.None
|
||||
overlay.DisplayOrder = 8
|
||||
overlay.Parent = playerGui
|
||||
|
||||
local function build(marker: BasePart)
|
||||
if arrows[marker] then return end
|
||||
local gui = Instance.new("BillboardGui")
|
||||
local gui = Instance.new("Frame")
|
||||
gui.Name = "ObjectiveArrow"
|
||||
gui.Adornee = marker
|
||||
gui.AlwaysOnTop = true
|
||||
gui.LightInfluence = 0
|
||||
gui.MaxDistance = 710
|
||||
gui.Size = UDim2.fromOffset(164, 164)
|
||||
gui.StudsOffsetWorldSpace = Vector3.yAxis * 13
|
||||
gui.Enabled = false
|
||||
gui.AnchorPoint = Vector2.new(.5, .5)
|
||||
gui.Size = UDim2.fromOffset(SIZE, SIZE)
|
||||
gui.BackgroundTransparency = 1
|
||||
gui.Visible = false
|
||||
|
||||
local viewport = Instance.new("ViewportFrame")
|
||||
viewport.Name = "ArrowViewport"
|
||||
@@ -33,7 +42,7 @@ local function build(marker: BasePart)
|
||||
|
||||
local camera = Instance.new("Camera")
|
||||
camera.FieldOfView = 31
|
||||
camera.CFrame = CFrame.lookAt(Vector3.new(0, 0, 9.7), Vector3.zero)
|
||||
camera.CFrame = CFrame.lookAt(Vector3.new(0, .8, 9.7), Vector3.zero)
|
||||
camera.Parent = viewport
|
||||
viewport.CurrentCamera = camera
|
||||
|
||||
@@ -66,7 +75,7 @@ local function build(marker: BasePart)
|
||||
end
|
||||
|
||||
arrows[marker] = arrow
|
||||
gui.Parent = playerGui
|
||||
gui.Parent = overlay
|
||||
end
|
||||
|
||||
local function add(instance: Instance)
|
||||
@@ -85,24 +94,29 @@ local added = arena.DescendantAdded:Connect(add)
|
||||
local removing = arena.DescendantRemoving:Connect(remove)
|
||||
for _, instance in arena:GetDescendants() do add(instance) end
|
||||
|
||||
local render = RunService.RenderStepped:Connect(function()
|
||||
local renderName = "HunterObjectiveArrows"
|
||||
RunService:BindToRenderStep(renderName, Enum.RenderPriority.Camera.Value + 3, function()
|
||||
local camera = workspace.CurrentCamera
|
||||
local active = player:GetAttribute("InArena") == true and camera ~= nil
|
||||
local active = player:GetAttribute("InArena") == true
|
||||
local now = os.clock()
|
||||
for marker, arrow in arrows do
|
||||
arrow.gui.Enabled = active and marker:GetAttribute("ObjectiveArrowHidden") ~= true
|
||||
if not arrow.gui.Enabled or not camera then continue end
|
||||
local distance = (camera.CFrame.Position - marker.Position).Magnitude
|
||||
if distance > arrow.gui.MaxDistance then continue end
|
||||
local phase = now * 3 + arrow.phase
|
||||
local size = math.clamp(math.floor(174 - distance * .11), 104, 174)
|
||||
arrow.gui.Size = UDim2.fromOffset(size, size)
|
||||
arrow.gui.StudsOffsetWorldSpace = Vector3.yAxis * (13 + math.sin(phase) * 1.05)
|
||||
local spacing = 1.15 + math.sin(phase - .9) * .24
|
||||
if not active or not camera or marker:GetAttribute("ObjectiveArrowHidden") == true
|
||||
or (camera.CFrame.Position - marker.Position).Magnitude > MAX_DISTANCE then
|
||||
arrow.gui.Visible = false
|
||||
continue
|
||||
end
|
||||
local projected = camera:WorldToViewportPoint(marker.Position)
|
||||
local phase = now * ANIMATION_RATE + arrow.phase
|
||||
local y = projected.Y - HEIGHT + math.sin(phase) * 7
|
||||
local screen = camera.ViewportSize
|
||||
arrow.gui.Visible = projected.Z > 0 and projected.X >= -SIZE / 2 and projected.X <= screen.X + SIZE / 2
|
||||
and y >= -SIZE / 2 and y <= screen.Y + SIZE / 2
|
||||
if not arrow.gui.Visible then continue end
|
||||
|
||||
arrow.gui.Position = UDim2.fromOffset(projected.X, y)
|
||||
local spacing = 1.15 + math.sin(phase - .9) * .16
|
||||
for index, chevron in arrow.chevrons do
|
||||
local level = 2 - index
|
||||
local tilt = CFrame.Angles(math.rad(-8), .22 + math.sin(phase * .72 + level * .35) * .26, 0)
|
||||
chevron:PivotTo(CFrame.new(0, level * spacing, 0) * tilt)
|
||||
chevron:PivotTo(CFrame.new(0, (2 - index) * spacing, 0))
|
||||
end
|
||||
local color = marker.Color
|
||||
if arrow.color ~= color then
|
||||
@@ -118,6 +132,6 @@ end)
|
||||
script.Destroying:Once(function()
|
||||
added:Disconnect()
|
||||
removing:Disconnect()
|
||||
render:Disconnect()
|
||||
for _, arrow in arrows do arrow.gui:Destroy() end
|
||||
RunService:UnbindFromRenderStep(renderName)
|
||||
overlay:Destroy()
|
||||
end)
|
||||
Reference in new issue
Block a user