Last active
November 11, 2018 13:43
-
-
Save tsubaki/1d51548412ba506cf52627b8a916db56 to your computer and use it in GitHub Desktop.
Raycastの発行(NavMeshQueryで)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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