using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace NodeCanvas.Tasks.Actions { [Category("Physics")] public class GetLinecastInfo2D : ActionTask { [RequiredField] public BBParameter target; public LayerMask mask = -1; [BlackboardOnly] public BBParameter saveHitGameObjectAs; [BlackboardOnly] public BBParameter saveDistanceAs; [BlackboardOnly] public BBParameter savePointAs; [BlackboardOnly] public BBParameter saveNormalAs; private RaycastHit2D hit; protected override void OnExecute() { hit = Physics2D.Linecast(agent.position, target.value.transform.position, mask); if ( hit.collider != null ) { saveHitGameObjectAs.value = hit.collider.gameObject; saveDistanceAs.value = hit.fraction; 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); } } }