Raycast grenade?

How can I make a script that casts out rays to all surrounding rigidbodies? I am trying to apply damage.

See this answer:


The bottom script has a simpler answer which just raycasts from the center of the grenade to the center of the object. The code above that does a more sophisticated raycast from the corners of the renderer bounding box. You will have to make a few changes based on the nature of your game.

Note this code is seeing if an object blocks the grenade. If you just want to find the objects to apply damage, you can use Physics.OverlapSphere().

Use a SphereCastAll. :slight_smile: