- Home /
Raycast without collider
Is there a way for my raycast to know when it hit an object without a collider? I am makin an FPS game and my capsule collider is not really modeled to my mesh and if i checked wether that collider is hit it would be really dumb because i could kill the player without even pointing at any of his body parts. Thx.
Answer by iwaldrop · Jun 27, 2013 at 06:11 PM
If you want collision detection on your mesh you have to use a mesh collider. This is not really advised, however, because of how computationally expensive it is to recompute the collider each frame. If you're targeting PCs then you might be able to get away with it for a few objects, but too many will cause a noticeable dip in frame rate. Mesh colliders, if used at all, are best used on static geometry that won't change or move (I.e. a chair, not a player character).
There really isn't anything wrong with using a capsule either. Its not really dumb, and a lot of games work this way in order to save computation time for other things that were deemed more important in the development cycle. Everything is a trade off, however, and if your game revolves around 'per-pixel hit detection' then that's where you spend your resources.
well the thing is i'm using stickmen, and if use a capsule collider i can shoot him without ...shooting him...if you get my drift...is there a workaround :S ?
Well, if by stickmen you mean a tall cube, you can decrease the radius of the capsule or use a box collider. $$anonymous$$eep in $$anonymous$$d that capsules are cheaper than boxes.
no, i mean actual stickmen, with arms, legs and a head (http://stickmanplayer.com/wp-content/uploads/2013/03/Stick_$$anonymous$$an.jpg something like that)
Oic. That would have been a good detail to include in the original question. Nonetheless, it seems that if you can't accept general collision detection then you're going to have to go with a mesh collider. Personally, I'd still use a capsule collider.
I suggest using multiple colliders then. If it's a stickman than a sphere for a head, capsule for body, etc.