Raycasting with tags problems in unity3d

Posted by user1855858 on Stack Overflow See other posts from Stack Overflow or by user1855858
Published on 2012-12-02T17:01:01Z Indexed on 2012/12/02 17:03 UTC
Read the original article Hit count: 323

Filed under:
|
|

i need some help here. i have a part of code to search unblocked neighbour with raycast. i need to get raycast that just collide with "WP" tag. both of the iteration shown a right results, so do the dump and the raycast, the raycast does success to collide something, but when i check what the raycast collided with, there is no result shown.... anyone knows whats wrong with this code..??

int flag = 0, flahNeigh = 0;
    for(flag = 0; flag< wayPoints.WPList.Length; flag++) // iteration to seek neighbour nodes
            { 
                for (flagNeigh = 0; flagNeigh < wayPoints.WPList.Length; flagNeigh++)
                {                
                    if (wayPoints.WPList[flag].loc != wayPoints.WPList[flagNeigh].loc) // dump its own node location
                    {                    
                        if (Physics.Raycast(wayPoints.WPList[flag].loc.position, wayPoints.WPList[flagNeigh].loc.position, out hitted)) // raycasting to each node else its self
                        {  
                            if (hitted.collider.gameObject.CompareTag("WP")) // check if the ray only collide the node
                            {
                               print(flag + "  :  " + flagNeigh + "  :  " + wayPoints.WPList[flagNeigh].loc.position); // debugging to see whether the code works or not (the error comes)
                            }
                        }
                    }                    
                }
            }

thanks for the appreciation and answers... sorry if i have a bad english...^^

© Stack Overflow or respective owner

Related posts about c#

Related posts about unity3d