RayCasting Not Working

Hello ,

I am Working on RayCasting … But , it is not happening to me . I have created a door and animated it and also attached a script to the FSP controller … The Script goes like this …

function update()
{

var hit : RaycastHit ;

if(Physics.Raycast(transform.position , transform.forward , hit ,5))
{
if(hit.collider.gameObject.tag == “MyDoor”)
{
hit.collider.gameObject.animation.Play(“Door_Slide”);
}

}

}

I have even tagged the door … But , when i start playing the animation is not taking place … Whereas , i have tried it with other function OnControllerColliderHit … This Works Fine only the RayCasting is not Working … Please , help me as soon as Possible

Do you get any errors in the debug window when you raycast ? are you standing close enough ? maybe add a debug line to the raycast :

function update()
{

    var hit : RaycastHit ;


    if(Physics.Raycast(transform.position , transform.forward , hit ,5))
    {
        if(hit.collider.gameObject.tag == "MyDoor")	
        {
            hit.collider.gameObject.animation.Play("Door_Slide ");
            Debug.Log ("Hitting: " + hit.collider.gameObject.name + " " + hit.collider.gameObject.tag);
        }
    }
}

you can also try this :

function update()
{

var hit : RaycastHit ;


if(Physics.Raycast(transform.position , transform.forward , hit ,5))
{
//    if(hit.collider.gameObject.tag == "MyDoor")	
//    {
//        hit.collider.gameObject.animation.Play("Door_Slide ");
        Debug.Log ("Hitting: " + hit.collider.gameObject.name + " " + hit.collider.gameObject.tag);
//    }
}

ya … i have tried the Debug line which you provided. But , there is no error … and I am not standing that close …

if you don’t get the debug message then the action is not fired at all. so the script isn’t attached to the player or something.

Yaaa … GOT IT!!! As you said … the action is not fired at all …that was correct …i checked it the script got corrupted although it was attached to the Player … I wrote a new script and then attached to the player … Now , it is Working …Thanks a lot Dude…
Done With Ray Casting …