Physics.Raycast would be exceptionally useful. If it Worked. Its probably not its fault but ive experimented and found, if i raycast towards my object which has a box collider, the raycast picks up a hit...good, but the minute i switch it to a character controller no dice. ive even set the layer mask to only pick up the layer the thing im shooting at is on. and it picks up nothing. Have a missed some setting somewhere or does raycast not like character controllers? if i dont set it to a layer mask it hits everything but goes right through the char controller. anyone have any clue why?
Use a trigger on your character in a child object specifically for use with the ray cast, should solve your problem
Hi there, I had this problem too, where raycasts wouldnt register intersections with character controllers. Try using Linecast instead, that worked for me.
If that doesnt work, try Spherecast.
See here for physics API commands: http://unity3d.com/support/documentation/ScriptReference/Physics.html
Im pretty sure Linecast uses the exact same function as Raycast, but just takes start and end points instead of an origin and direction; so just use this:
static function Linecast (start : Vector3, end : Vector3, out hitInfo : RaycastHit, layerMask : int = kDefaultRaycastLayers) : boolean
form of the function for the exact same - pardon, better results than you would using the raycast.
Good luck!