When I am trying to make an animation using raycasting and make the effects with adornments they will become offsetted when I used object space with the character’s rootpart but if I use just world space they become in the correct spot. I want it to be with adorned with the root part and have the same cframe like the world cframe one.
The Code;
for i,v in ipairs(GetGrid) do
local GetCharPos = v * CFrame.new(-GetVector3.X,0,-GetVector3.Z)
local Direction = v.LookVector*( (v.Position-GetCharPos.Position).Magnitude*10)
local FindRay = workspace:Raycast(v.Position,Direction)
if FindRay and FindRay.Instance then
local Example = Instance.new("BoxHandleAdornment",workspace.Terrain)
local Distance = (v.Position - FindRay.Position).Magnitude
Example.Size = Vector3.new(.025,.025,Distance)
local FindMid = rootpart.CFrame:ToWorldSpace(workspace.Terrain.CFrame)
Example.CFrame = (CFrame.lookAt(v.Position,FindRay.Position) * CFrame.new(0,0,-Distance/2) ):ToObjectSpace(rootpart.CFrame)
--Example.CFrame = Example.CFrame:ToObjectSpace(FindMid)
--Example.CFrame = Example.CFrame:ToObjectSpace(rootpart.CFrame)
Example.AlwaysOnTop = true
Example.Color3 = Color3.fromHSV(0.985556, 1, 0.985946)
Example.Adornee = rootpart--workspace.Terrain
Debris:AddItem(Example,.4)
end
end