Hello. Im trying to make an infinite ray lengh but I have no idea how to do it. I know how to make a limited length ray and I do it like this
var rayLength : float = 100;
var hit : RaycastHit;
var forward = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position,
forward, hit, rayLengh))
{
code();
}
How do I make it infinite ? Thank you. I hope I was clear enough.
The code im using :
function Shoot()
{
var hit : RaycastHit;
var forward = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, forward, hit, Mathf.Infinity))
{
var Gun : Transform;
Gun = Instantiate(bullet, barrelEnd.position, transform.rotation);
Gun.LookAt(hit.point);
w();
wep.animation.Play("Shoot");
audio.PlayOneShot(shootSoundEffect);
}
}