Skip to content

Commit 823b788

Browse files
committed
Fixed bug with orb tweening.
1 parent 01bb54c commit 823b788

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

src/client/Gui.lua

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ function Gui.Init()
272272

273273
ContextActionService:BindAction("OrbcamToggle", HandleActivationInput, false, ORBCAM_MACRO_KB[#ORBCAM_MACRO_KB])
274274

275-
-- Handle orb tweening
276275
OrbTweeningStartRemoteEvent.OnClientEvent:Connect(Gui.OrbTweeningStart)
277276
OrbTweeningStopRemoteEvent.OnClientEvent:Connect(Gui.OrbTweeningStop)
278277

@@ -834,18 +833,17 @@ function Gui.OrbTweeningStart(orb, waypoint, poi)
834833
end
835834

836835
if poi == nil then
837-
print("[Orb] Warning: OrbTweeningStart passed a nil poi")
836+
print("[Orb] WARNING: OrbTweeningStart passed a nil poi")
838837
end
839838

840839
-- Start camera moving if it is enabled, and the tweening
841840
-- orb is the one we are attached to
842-
if Gui.Orb and orb == Gui.Orb and Gui.Orbcam then
841+
if orb == Gui.Orb and Gui.Orbcam then
843842
Gui.OrbcamTweeningStart(waypoint.Position, poi)
844843
end
845844

846845
-- Store this so people attaching mid-flight can just jump to the target CFrame and FOV
847-
targetForOrbTween[orb] = { Waypoint = waypoint,
848-
Poi = poi }
846+
targetForOrbTween[orb] = { Waypoint = waypoint:Clone(), Poi = poi:Clone() }
849847

850848
orb:SetAttribute("tweening", true)
851849
Gui.RefreshPrompts(orb)
@@ -857,9 +855,8 @@ function Gui.OrbTweeningStop(orb)
857855
Gui.RefreshPrompts(orb)
858856
end
859857

860-
-- Note that we will refuse to move the camera if there is nothing to look _at_
861858
function Gui.OrbcamTweeningStart(newPos, poi)
862-
if Gui.Orbcam == nil then return end
859+
if not Gui.Orbcam then return end
863860
if newPos == nil then
864861
print("[Orb] OrbcamTweeningStart passed a nil position")
865862
return

src/common/Config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local Config = {
44
WaypointTag = "metaorb_waypoint",
55
PointOfInterestTag = "metaorb_poi",
66
DataStoreTag = "orb.",
7-
Version = "0.7.7",
7+
Version = "0.7.8",
88
TweenTime = 5,
99
RopeLength = 10,
1010
TransportWaitTime = 10,

src/server/Orb.lua

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function Orb.Init()
3939
Orb.Attachments = {} -- (tostring(playerID) -> orb)
4040
Orb.ListeningStatus = {} -- Which players are listening to an orb? For halos (tostring(playerID) -> bool)
4141
Orb.OrbCamStatus = {} -- Which players are watching through orbcam? (tostring(playerID) -> bool)
42+
Orb.SpeakerLastMoved = {} -- (tostring(playerID) -> last move time)
4243

4344
local orbs = CollectionService:GetTagged(Config.ObjectTag)
4445
for _, orb in ipairs(orbs) do
@@ -76,6 +77,12 @@ function Orb.Init()
7677

7778
OrbSpeakerMovedRemoteEvent.OnServerEvent:Connect(function(plr, orb)
7879
if not plr.Character then return end
80+
81+
local lastMoveTime = Orb.SpeakerLastMoved[tostring(plr.UserId)]
82+
if lastMoveTime ~= nil and lastMoveTime > tick() - 5 then return end
83+
84+
Orb.SpeakerLastMoved[tostring(plr.UserId)] = tick()
85+
7986
local playerPos = plr.Character.PrimaryPart.Position
8087

8188
local waypointPos = Orb.TweenOrbToNearPosition(orb, playerPos)
@@ -666,15 +673,15 @@ end
666673

667674
function Orb.TweenOrbToNearPosition(orb, pos)
668675
local waypoints = CollectionService:GetTagged(Config.WaypointTag)
669-
670676
if #waypoints == 0 then return orb:GetPivot().Position end
671677

672-
-- Find the closest waypoint to the new position
673-
-- and move the orb there
678+
-- Find the closest waypoint to the new position and move the orb there
674679
local minDistance = math.huge
675680
local minWaypoint = nil
676681

677682
for _, waypoint in ipairs(waypoints) do
683+
if not waypoint:IsDescendantOf(game.Workspace) then continue end
684+
678685
local distance = (waypoint.Position - pos).Magnitude
679686
if distance < minDistance then
680687
minDistance = distance
@@ -683,7 +690,6 @@ function Orb.TweenOrbToNearPosition(orb, pos)
683690
end
684691

685692
if minWaypoint ~= nil then
686-
-- If we are already there, don't tween
687693
if (minWaypoint.Position - orb:GetPivot().Position).Magnitude < 0.01 then
688694
return orb:GetPivot().Position
689695
end
@@ -723,16 +729,13 @@ function Orb.TweenOrbToNearPosition(orb, pos)
723729
OrbTweeningStopRemoteEvent:FireAllClients(orb)
724730
end)
725731

726-
-- Note that if the position is already being tweened, this will
727-
-- stop that tween and commence this one
728732
orbTween:Play()
729-
730-
-- Announce this tween to clients
731733
OrbTweeningStartRemoteEvent:FireAllClients(orb, minWaypoint, poi)
732734

733735
return minWaypoint.Position
734736
end
735737

738+
print("[MetaOrb] Failed to find near waypoint")
736739
return orb:GetPivot().Position
737740
end
738741

@@ -883,6 +886,7 @@ function Orb.PointOfInterest(targetPos)
883886
for _, family in ipairs(families) do
884887
for _, p in ipairs(family) do
885888
if CollectionService:HasTag(p, "metaboard_personal") then continue end
889+
if not p:IsDescendantOf(game.Workspace) then continue end
886890

887891
local pos = p:GetPivot().Position
888892

@@ -895,6 +899,10 @@ function Orb.PointOfInterest(targetPos)
895899
end
896900
end
897901

902+
if closestPoi == nil then
903+
print("[MetaOrb] Failed to find closest point of interest")
904+
end
905+
898906
return closestPoi, closestPos
899907
end
900908

0 commit comments

Comments
 (0)