I’m currently wondering how I could get a Vector3, two studs away from the green direction. Do I use LookVector, RayCasting, or else to do this?
1 Like
DistanceFromCharacter
would answer that if you’re tracking it relatively to a player.
Although the above, this is more of a vector thing, try calculating only one vector. LookVector
may be involved if the origin is alternated from the global space.
1 Like
Depends on what you want it relative to.
Should it always go West or should it go Left of the position?
If you wanted it to go west, you could simply do
Vector = OriginVector + Vector3.new(-2,0,0)
If you wanted it to be relative, you could do
Vector = (CFrame.new(OriginVector)*CFrame.new(-2,0,0)).p
Also, if you want to forcibly set tthe position of a Part, you need to use CFrame
Part.CFrame = CFrame.new(Vector)
3 Likes
I tried to make it go relatively or locally, but it only went towards the global z-direction? Which is not what I’m trying to do.
function ArrowService:MoveToDirection(arrow)
local pos = (CFrame.new(arrow.PrimaryPart.Position)*CFrame.new(0,0,-20)).p
self:CreateTarget(pos)
delay(1, function()
print("Creating arrow!")
--arrow:Destroy()
end)
end
function ArrowService:CreateTarget(pos)
local Target = Instance.new("Part")
Target.Name = "Target"
Target.Anchored = true
Target.Size = Vector3.new(1,1,1)
Target.CFrame = CFrame.new(pos)
Target.Parent = game.Workspace
delay(1, function()
print("Destroying target.")
--Target:Destroy()
end)
end
I want it to go 20 studs towards the red line, which is where it is facing.