What do you want to achieve? rotating the arrow from my compass on real time and without delay (stay inside the compass and not outside while moving with my character)
What solutions have you tried so far? I did ask the developper of Square piece (for those who knows him) because he got something similar. He did tell me some tips but still can’t achieve it
The localscript just open/close a GUI to pick a destination. The red part of the arrow will point the direction to follow.
the value IslPos contains the Vector3 value of the position
The script named “pointing” is the following code
local arrow = script.Parent
local sphere = arrow.Parent:FindFirstChild("sphere")
local weld = Instance.new("Weld", arrow)
weld.Part0 = arrow
weld.Part1 = sphere
for i = 0, math.huge do
weld.C1 = weld.C1 * CFrame.new(arrow.CFrame.Position, arrow.Parent.Parent:FindFirstChild("IslPos").Value)
wait()
end
i’ve tried to think by myself and this is the first time i ask for help. But i think that this time i can’t achieve it alone.
i would be thankfully to the one which give me a solution for my problem.
okay, just tested it in studio, use a weld constraint(not a weld) and weld the arrow to the handle, set the handle as part0 and arrow as part1, then just change the orientation of the arrow.
local p1 = Vector3.new() --the vector3 of the object
local p2 = Vector3.new() --the vector3 of the arrow
local xOffset = p2.X - p1.X
local zOffset = p2.Z - p1.Z
local rotation = math.deg(math.atan2(zOffset, xOffset))
try setting the y orientation of the arrow to rotation, (if might need to try setting the x or z axis rather than the y)… this should point the arrow in the direction of the object you want it to point to.
local arrow = script.Parent
local val = arrow.Parent.Parent:FindFirstChild("IslPos")
for i = 0, math.huge do
local p1 = Vector3.new(val.Value) --the vector3 of the object
local p2 = Vector3.new(arrow.Position) --the vector3 of the arrow
local xOffset = p2.X - p1.X
local zOffset = p2.Z - p1.Z
local rotation = math.deg(math.atan2(zOffset, xOffset))
arrow.Orientation = Vector3.new(0, 90, 0)
wait()
end
okey so i tested some rotations and even if it point to right direction, the arrow isnt on the right direction https://gyazo.com/c760cba75ad8dbae23d05cf60c5d9944
actually it does point the part in front of my character
you did give a precious help until now. I tried some rotations and the fact is, it does change for every island. If the red point the right direction for the first island, it is random for the others.
This is the actual script:
local arrow = script.Parent
local val = arrow.Parent.Parent:FindFirstChild("IslPos")
for i = 0, math.huge do
local p1 = val.Value --the vector3 of the object
local p2 = arrow.Position --the vector3 of the arrow
local xOffset = p2.X - p1.X
local zOffset = p2.Z - p1.Z
local rotation = math.deg(math.atan2(zOffset, xOffset))
arrow.Orientation = Vector3.new(0, rotation + 225, -90)
wait()
end