Skip to content

Conversation

@Nickauhla
Copy link

Switched from Vector2 to Vector3, as we are in 3D.

Improved the hitpoint calculation, as with a SphereCast, we must pay attention to:
SphereCast will not detect colliders for which the sphere overlaps the collider. Passing a zero radius results in undefined output and doesn't always behave the same as Physics.Raycast.

We calculate the closest point on the ray (direction of the spherecast) to the center of the collider. Then we ask Unity to give us the closest point from it on the collider. We consider this new point as our Hit point and use it for further calculation.

Nickauhla added 2 commits May 4, 2020 12:10
Switched from Vector2 to Vector3, as we are in 3D.

Improved the hitpoint calculation, as with a SphereCast, we must pay attention to:
**SphereCast will not detect colliders for which the sphere overlaps the collider. Passing a zero radius results in undefined output and doesn't always behave the same as Physics.Raycast.**

We calculate the closest point on the ray (direction of the spherecast) to the center of the collider. Then we ask Unity to give us the closest point from it on the collider. We consider this new point as our Hit point and use it for further calculation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant