#pragma strict
var dot : Transform;
var defDotPos : Vector3 = Vector3(0, 1000, 0);
function Update()
{
var ray = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if (Physics.Raycast(transform.position , ray , hit, 150))
{
dot.position = hit.point;
}
else
{
dot.position = defDotPos;
}
}
This script is supposed to show a point(sphere) on the object which is in front of the character, but actually it loops sphere between character and that object. here is picture so you can see Screenshot by Lightshot
It creates a sphere where it hit
then the raycast hits the sphere in its new position, so moves it closer to the the player
then the raycast hits the sphere in its new position, so moves it closer to the the player
then the raycast hits the sphere in its new position, so moves it closer to the the player
then the raycast hits the sphere in its new position, so moves it closer to the the player
etc
Remove the collider from the sphere