using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace NodeCanvas.Tasks.Actions { [Category("Physics")] public class GetLinecastInfo : ActionTask { [RequiredField] public BBParameter target; public BBParameter layerMask = (LayerMask)( -1 ); [BlackboardOnly] public BBParameter saveHitGameObjectAs; [BlackboardOnly] public BBParameter saveDistanceAs; [BlackboardOnly] public BBParameter savePointAs; [BlackboardOnly] public BBParameter saveNormalAs; private RaycastHit hit = new RaycastHit(); protected override void OnExecute() { if ( Physics.Linecast(agent.position, target.value.transform.position, out hit, layerMask.value) ) { saveHitGameObjectAs.value = hit.collider.gameObject; saveDistanceAs.value = hit.distance; savePointAs.value = hit.point; saveNormalAs.value = hit.normal; EndAction(true); return; } EndAction(false); } public override void OnDrawGizmosSelected() { if ( agent && target.value ) Gizmos.DrawLine(agent.position, target.value.transform.position); } } }