void Raycasting() { float m = -1f; for (int i = 0; i < 8; i++) { RaycastHit2D ray = Physics2D.Raycast(transform.position, new Vector2(Mathf.Cos(m), Mathf.Sin(m)), distance, 10); rays.Add(ray); m += Mathf.PI / 8 * 10; //Debug.DrawRay(transform.position, new Vector2(Mathf.Cos(m), Mathf.Sin(m)), Color.green, distance); } foreach (RaycastHit2D hit in rays) { if(hit.collider != null /*&& hit.collider.gameObject.layer != LayerMask.NameToLayer("Enemy")*/) { Debug.Log(hit.collider.name + " Hit the Ray!"); Debug.Log("At a distance of " + Vector2.Distance(hit.point, transform.position)); if(hit.collider.name == "Player") rayHit = RayHitType.player; if (hit.collider.name == "Wall") rayHit = RayHitType.wall; } } }
public PrimeEngine(RayFormat rayFormat, RayHitType hitType, RTPBufferType bufferType = RTPBufferType.Host, bool useCPU = false) { _rayFormat = rayFormat; _hitType = hitType; _bufferType = bufferType; _context = new PrimeContext(!useCPU); }
// Update is called once per frame void Update() { rayHit = RayHitType.nothing; rays = new List<RaycastHit2D>(); Raycasting(); }
internal SurfaceProgram(Context ctx, RayHitType type, IntPtr program):base(ctx, program) { RayType = type; }
/// <summary> /// Creates a program located at [filename] with main function [programName] /// </summary> /// <param name="context">Context with which to create the program.</param> /// <param name="type">Type of ray this program represents. <seealso cref="RayHitType"></seealso></param> /// <param name="filename">Path of the compiled cuda ptx file holding the program.</param> /// <param name="programName">Name of the main function of the program.</param> public SurfaceProgram(Context context, RayHitType type, String filename, String programName) :base(context, filename, programName) { RayType = type; }