Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active November 11, 2018 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/1d51548412ba506cf52627b8a916db56 to your computer and use it in GitHub Desktop.
Save tsubaki/1d51548412ba506cf52627b8a916db56 to your computer and use it in GitHub Desktop.
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