How To Make The Raycast Thicker!

Hello Everyone i want to know how to make the Raycast Thicker

i use this code

if(Physics.Raycast(transform.position + new Vector3(0,0.6f,-1.6f),transform.TransformDirection(Vector3.forward),out hit)){	


}

3 Answers

3
float thickness = 1f; //<-- Desired thickness here.
Vector3 origin = transform.position + new Vector3(0,0.6f,-1.6f);
Vector3 direction = transform.TransformDirection(Vector3.forward);
if (Physics.SphereCast(origin, thickness, direction, out hit)) {
    ...
}

I didn't realise a SphereCast worked this way! I thought SphereCast was the same as CheckSphere >< Purged my silly suggestions and rating you guys up :)

how do i see a debug.drawray of it? tanks!

You can’t make a raycast thicker; a ray by definition is one-dimensional. You can try using a spherecast instead.

more info about spherecast Please? can you right the C# code using my vectors

Just look it up in the docs.

so spherecast is same as raycast but thicker?

spherecast is spherecast. you can use multiple raycasts(like 3 or 4) in a small area to simulate a Thicker raycast.

i want thicked raycast because i need this : when i'm aim on the box, will show GUI.label "its a Box" but with raycast its only show when i AIM i need it to showup when the box in range around the raycast any ideas? and sry for bad english

And for 2D projects, you could use CircleCast :slight_smile: