I have a crosshair image on my canvas but I don’t know how to get it to follow the player’s position. I was told that I could use raycast, but how would I go about changing the crosshair’s position according to the raycast of the player?
I like to use this javascript. All you have to do is attach it to the crosshairs and set target as player. Although it doesn’t use raycast it works well. Also if it doesn’t line up to the exact spot you want it to you could add + 1 to the end of a line or whatever you please.
#pragma strict
var target: Transform;
function Update () {
transform.position.x = target.position.x ;
transform.position.y = target.position.y ;
transform.position.z = target.position.z;
}