Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Raycasting] How to change center of CFramed object?

Asked by 6 years ago
Edited 6 years ago

Please read title, it explains everything I'm trying to accomplish.

My problem is that I want the beam to be centered on its edge but not on its actual center, help!







game:GetService("RunService").RenderStepped:Connect(function() local beam = game.workspace:WaitForChild("TargetDirection") beam.Name = 'TargetDirection' beam.CanCollide = false local Target = game.Workspace:FindFirstChild("Lock On!") local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart") local ray = Ray.new(Target.CFrame.p, (HumanoidRootPart.CFrame.p - Target.Position).unit) local AnchorPoint = script:WaitForChild("AnchorPoint") if (Target.Position - HumanoidRootPart.Position).magnitude < 20 then beam.BrickColor = BrickColor.new("Lime green") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0 beam.Anchored = true beam.Locked = true beam.CanCollide = false beam.Shape = Enum.PartType.Cylinder beam.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction)* CFrame.Angles(0,math.pi/2,0); beam.Size = Vector3.new(((Target.Position - HumanoidRootPart.Position) + AnchorPoint.Value).magnitude, 0.05, 0.05); else beam.Transparency = 1 end end)
0
Offset it in the z-axis by half its length. Otherwise, the beam will be centered exactly on the player. XAXA 1569 — 6y
0
@XAXA Size or Position? JoeRaptor 72 — 6y
0
Its CFrame. XAXA 1569 — 6y
0
@XAXA the position of the CFrame or the Rotation of the CFrame? JoeRaptor 72 — 6y
View all comments (3 more)
0
@XAXA Also, dividing the Z Axis's position does not achieve my desired result sadly, do you have any other ideas? JoeRaptor 72 — 6y
0
@TheeDeathCaster I have no idea how to use that correctly within what the wiki gives me. JoeRaptor 72 — 6y

Answer this question