I
I
ikeky2020-07-30 14:43:31
Unity
ikeky, 2020-07-30 14:43:31

What analog can be found for Physics.SphereCast?

The video is an example of what I need to achieve.
I'm trying to make the movement of the chip equal to its diameter, the movement is instantaneous and only in free space. To improve the display of such a movement, we decided to make a stroke that he can go to.
Physics.SphereCast is a good method, the method almost came up, but one nuance interferes with the gameplay.
5f22b05ece992702719397.png
In this situation, the token cannot move to an empty cell marked with a black outline, due to the fact that the SphereCast collides with an object in the green-colored space.
I need to find another solution to this problem, or use crutches for SphereCast.
Here is the code:

origin = transform.position;
        direction = transform.forward * (-1); 
        RaycastHit hit;
        if(Physics.SphereCast(origin, sphereRadius, direction, out hit, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal)){
            currentHitObject = hit.transform;
            currentHitDistance = hit.distance;
        } else {
            currentHitDistance = maxDistance;
            advanceDisplay.position = transform.position + (transform.forward * (-1) * currentHitDistance);
            currentHitObject = null;
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question