Hello...
Im making a FPS on C# and im having some problems with the Raycast.
Vector3 fwd = direction.transform.position;
RaycastHit hit;
if (Physics.Raycast(fwd, transform.forward, out hit)) ;
{
Debug.DrawRay(fwd, transform.forward, Color.red, 5F);
if (hit.transform.gameObject.tag == "Wall")
{
print("HITwall");
}
if (hit.transform.gameObject.tag == "Enemy")
{
//print("HITenemy");
GameObject.FindWithTag("Enemy").GetComponent().DmgOn = true;
}
The draw should begin at the *direction* position (the *direction* is an empty gameobject attached to the gun), but its starting far away from it.
![Error][1]
The red line is the draw from the *Debug.DrawRay*.
Can someone help?? I dont know what to do.
Tnks!
[1]: http://i.imgur.com/3Z0D9.jpg
↧