Exemplo n.º 1
0
    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;
            }
        }        
    }
Exemplo n.º 2
0
 public PrimeEngine(RayFormat rayFormat, RayHitType hitType, RTPBufferType bufferType = RTPBufferType.Host, bool useCPU = false)
 {
     _rayFormat  = rayFormat;
     _hitType    = hitType;
     _bufferType = bufferType;
     _context    = new PrimeContext(!useCPU);
 }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     rayHit = RayHitType.nothing;
     rays = new List<RaycastHit2D>();
     Raycasting();
 }
Exemplo n.º 4
0
 internal SurfaceProgram(Context ctx, RayHitType type, IntPtr program):base(ctx, program)
 {
     RayType = type;
 }
Exemplo n.º 5
0
 /// <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;
 }