Horje
unity reflect raycast Code Example
raycast unity
RaycastHit hit;
        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
        {
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
            Debug.Log("Hit");
        }
        else
        {
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white);
            Debug.Log("No Hit");
        }
unity reflect raycast
Ray ray = new Ray(position, direction);
RaycastHit hit2;
if (Physics.Raycast(ray, out hit2, maxStepDistance))
{
    reflDirection = Vector3.Reflect(direction, hit2.normal);
    hitPosition = hit2.point;
}
else
{
    position += reflDirection * maxStepDistance;
}

Debug.DrawRay(hitPosition, reflDirection, Color.green);




Csharp

Related
animation setbool unity Code Example animation setbool unity Code Example
linq dynamic order by descending Code Example linq dynamic order by descending Code Example
find the values of dictionaries in C sharp Code Example find the values of dictionaries in C sharp Code Example
Unity rigidbody drag and top speed relation Code Example Unity rigidbody drag and top speed relation Code Example
C# program that joins List of strings Code Example C# program that joins List of strings Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11