Skip to content

Instantly share code, notes, and snippets.

@tsubaki tsubaki/RaycastCheck.cs
Last active Nov 11, 2018

Embed
What would you like to do?
Raycastの発行(NavMeshQueryで)
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Experimental.AI;
public class RaycastCheck : MonoBehaviour
{
[SerializeField] Transform start, target;
private void OnEnable()
{
// 事前準備
NavMeshWorld world = NavMeshWorld.GetDefaultWorld();
NavMeshQuery query = new NavMeshQuery(world, Unity.Collections.Allocator.Persistent);
// Raycast発行
NavMeshLocation location = query.MapLocation(start.position, Vector3.up * 10, 0);
PathQueryStatus status = query.Raycast(out NavMeshHit hitCheck, location, target.position);
Debug.LogFormat("IsHit:{0}, status:{1}", hitCheck.hit, status);
// 後片付け
query.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.