This commit is contained in:
gechangfu 2025-07-30 11:25:55 +08:00
parent d00ce59006
commit 678c6035a9
3 changed files with 10 additions and 37 deletions

1
sourcemap.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -5,40 +5,8 @@ local RunService = game:GetService("RunService")
local player = Players.LocalPlayer local player = Players.LocalPlayer
local camera = workspace.CurrentCamera local camera = workspace.CurrentCamera
-- local CAMERA_DISTANCE = 20
-- local CAMERA_HEIGHT = 20
-- local CAMERA_ANGLE = math.rad(-45)
-- local SCREEN_OFFSET = 5 -- 让角色在画面下方,数值越大越靠下
-- local function getCharacterRoot()
-- local character = player.Character
-- if character then
-- return character:FindFirstChild("HumanoidRootPart") or character:FindFirstChildWhichIsA("BasePart")
-- end
-- return nil
-- end
-- RunService.RenderStepped:Connect(function()
-- local root = getCharacterRoot()
-- if root then
-- -- 让lookAt点在角色身后一点以角色朝向为基准反方向偏移
-- local lookAt = root.Position - Vector3.new(-1, 0, 0) * SCREEN_OFFSET
-- -- 相机位置俯视角Y高度固定
-- local offset = Vector3.new(
-- -CAMERA_DISTANCE * math.cos(CAMERA_ANGLE),
-- CAMERA_HEIGHT,
-- 0
-- )
-- local cameraPos = lookAt + offset
-- camera.CameraType = Enum.CameraType.Scriptable
-- camera.CFrame = CFrame.new(cameraPos, lookAt)
-- end
-- end)
local CAMERA_DISTANCE = 20 local CAMERA_DISTANCE = 20
local CAMERA_HEIGHT = 20 local CAMERA_HEIGHT = 40
local CAMERA_ANGLE = math.rad(-45) local CAMERA_ANGLE = math.rad(-45)
local SCREEN_OFFSET = 5 local SCREEN_OFFSET = 5

View File

@ -1,3 +1,5 @@
-- 控制玩家和敌人的血条显示
local HealthBar = {} local HealthBar = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ReplicatedStorage = game:GetService("ReplicatedStorage")
@ -5,7 +7,9 @@ local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players") local Players = game:GetService("Players")
local BoardFolder = ReplicatedStorage:WaitForChild("UI"):WaitForChild("Board") local BoardFolder = ReplicatedStorage:WaitForChild("UI"):WaitForChild("Board")
local HeadBar = BoardFolder:WaitForChild("HeadBar") local HeadBarEnemy = BoardFolder:WaitForChild("HeadBarEnemy")
local HeadBarPlayer = BoardFolder:WaitForChild("HeadBarPlayer")
local LocalPlayer = Players.LocalPlayer local LocalPlayer = Players.LocalPlayer
local MobsFolder = Workspace:WaitForChild("Mobs"):WaitForChild(LocalPlayer.UserId) local MobsFolder = Workspace:WaitForChild("Mobs"):WaitForChild(LocalPlayer.UserId)
@ -42,12 +46,12 @@ local function SetHealthBar(child, prefab)
end end
-- 玩家自己特殊监听 -- 玩家自己特殊监听
SetHealthBar(Character, HeadBar) SetHealthBar(Character, HeadBarPlayer)
-- 监听玩家角色重新生成暂时没放在Connections中 -- 监听玩家角色重新生成暂时没放在Connections中
LocalPlayer.CharacterAdded:Connect(function(newCharacter) LocalPlayer.CharacterAdded:Connect(function(newCharacter)
Character = newCharacter Character = newCharacter
SetHealthBar(Character, HeadBar) SetHealthBar(Character, HeadBarEnemy)
end) end)
@ -55,7 +59,7 @@ end)
-- TODO: 监听玩家怪物目录下的怪物增减,处理对应血条 -- TODO: 监听玩家怪物目录下的怪物增减,处理对应血条
MobsFolder.ChildAdded:Connect(function(child) MobsFolder.ChildAdded:Connect(function(child)
if child:IsA("Model") then if child:IsA("Model") then
SetHealthBar(child, HeadBar) SetHealthBar(child, HeadBarEnemy)
end end
end) end)