How ui arrow looking at work and how to make it?

I’m trying to make a UI Arrow that aims like this image
The issue, is how am I able to make it look at?
how, as I search on developer.roblox.com i couldnt find the one where i want it to be
image

2 Likes

Essentially you would need an image of the arrow/shape, and you would rotate in on the screen mapped to the rotation around the player (i.e. front of the player corresponds with up on the GUI, and behind the player corresponds with the bottom of the GUI). To do this you could use the Rotation method of a GUI Element. You could have a frame which is invisible and centred on the screen, namely your ‘pivot’, and then have a child in that which is the image itself. You can then offset the image from the parent, and when the 'pivot’s rotation value is changed, the image should change direction. I would be happy to work some code for you, but I would need some more information such as how the event is triggered, and how the event triggered know what direction it is facing.

Good luck and happy coding!

If you are wanting to show the direction a player was hit from then you would need to get where the player was hit. So if you are using raycasting or a projectile I would make it create a temporary value or something so that the player can get it.
From there you will have a central position(Cameras) and work out which direction it is in.

2 Likes

Got an issue here

https://gyazo.com/4ad190322d5752a1889ea19c4a0a992c

When arrow aims at the target and i move the camera away the arrow wont rotate and will stay till i start to move around the target
if camera gets closer to the target it rotates but first person rotating i out of clue
i checked how pointtoobjectspace and i couldnt find the way too
somewhat dead end, any help would be appreciated

local target = Vector3.new(0,0,0)
local temppart = Instance.new("Part")
temppart.Transparency = 1
temppart.CanCollide = false
temppart.Anchored = true

game:GetService("RunService").RenderStepped:Connect(function()
local rotation = temppart.Orientation.Y
temppart.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position,target)
script.Parent.Rotation = rotation
end)
2 Likes

I’m pretty sure you just need to swap lines 8 and 9 from:

local rotation = temppart.Orientation.Y
temppart.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position,target)

to:

temppart.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position,target)
local rotation = temppart.Orientation.Y

And also you need to adjust for the camera’s rotation as an offset. Perhaps something like this:

local target = Vector3.new(0,0,0)
local temppart = Instance.new("Part")
local camera = workspace.CurrentCamera

temppart.Transparency = 1
temppart.CanCollide = false
temppart.Anchored = true

game:GetService("RunService").RenderStepped:Connect(function()
    temppart.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position,target)    
    local rotation = temppart.Orientation.Y
    script.Parent.Rotation = rotation - camera.CFrame:ToEulerAnglesXYZ().Y
end)
2 Likes

I got frustriated on trying to make it work with devforum compass ui’s
The only problem i have is arrow should aim at targetted object when camera changes rotation and it didnt work, i tried pointtoobjectspace and no result
same with your help