Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a game object on screen represented by a cube (but say it was a quad or something else all the same).

How do I raycast to check intersections? Keeping in mind I may not be raycasting fora physical object, just a gameobject of any sort.

Another question I have is, how can you raycast in Unity3D just to check against an intersection against anything in general (say the first gameobject to be hit)?

share|improve this question
4  
Physics.Raycast. Your object needs to have a collider. Depending on what you're doing a Rigidbody.SweepTest may also be useful. – Jonathan Connell Sep 25 '11 at 12:19
1  
Consider using trigges instead of raycasts, as triggers perform much better than recurring raycasts. – jonas Sep 27 '11 at 9:10
1  
@Jonathan Why did you not post that as an answer!? All my upvote are belong to you! – Anko Dec 3 '11 at 18:39

1 Answer

If you want to stay with Raycasting, when you load your object, keep track of the faces in some way. Then raycast to the triangles instead of the whole object. This greatly improves your accuracy of your raycast, also built in an algorith that improves the raycasting technique

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.