- Home /
how to make a raycast have a wider range of hit
i dont know if this makes sense or not but its like this, when you create a raycast it hits the object that's in front of it. is it possible to make the raycast hit any object on the screen no matter where it is on the screen.
Simply use more than one raycast dude. It's that simple. Sphere cast is nothing to do with what you want here, I'd forget about that
Answer by Owen-Reynolds · Jun 02, 2012 at 06:53 PM
A raycast can be a wider SphereCast, but it can't get wider and wider like a cone. Mostly because people use other things for cones.
If you just want to check if something is on the screen, can use renderer.isVisible
. If you want to find all enemies in a cone in front of you, most people go through a list of enemies and check the angle is small enough, something like: Vector3.Angle(transform.forward, enemy[i].position-transform.position)<30
.
no i made the cone just to show u the camera spherecast is what i was looking for
Answer by Tasarran · Jun 03, 2012 at 03:11 AM
You could fire multiple rays, say at a grid of points...
If you keep it low, like 5x5 it would be workable.
And if you use SphereCasts also, it will make sure nothing gets missed. (SphereCast is essentially a fat RayCast).
Your answer
Follow this Question
Related Questions
Ray from enemy to player is always a bit off (Image) 1 Answer
RaycastHit.distance 1 Answer
Hit distance Change light range 1 Answer
How to hit two objects with only one shot (raycast) 0 Answers
Need help with Third person shooter 0 Answers