docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method TryGetHitInfo

    TryGetHitInfo(out Vector3, out Vector3, out int, out bool)

    Gets the current ray cast hit information, if a hit occurs. It returns the world position and the normal vector of the hit point, and its position in linePoints.

    Declaration
    public bool TryGetHitInfo(out Vector3 position, out Vector3 normal, out int positionInLine, out bool isValidTarget)
    Parameters
    Type Name Description
    Vector3 position

    When this method returns, contains the world position of the ray impact point if a hit occurred.

    Vector3 normal

    When this method returns, contains the world normal of the surface the ray hit if a hit occurred.

    int positionInLine

    When this method returns, contains the index of the sample endpoint within the list of points returned by GetLinePoints(ref Vector3[], out int) where a hit occurred. Otherwise, a value of 0 if no hit occurred.

    bool isValidTarget

    When this method returns, contains whether both a hit occurred and it is a valid target for interaction.

    Returns
    Type Description
    bool

    Returns true if a hit occurs, implying the ray cast hit information is valid. Otherwise, returns false.

    Implements
    ILineRenderable.TryGetHitInfo(out Vector3, out Vector3, out int, out bool)
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)