Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Licht : MonoBehaviour {
- public int gk = 0;
- public int Range = 0;
- public Vector3[] hitted = new Vector3[360];
- public PolygonCollider2D col;
- void Start () {
- print (col.points[1]);
- }
- void Update () {
- RaycastHit2D Test = Physics2D.CircleCast(transform.position,Range,transform.position);
- if(Test.collider != null)
- {
- for(int i = 0;i<gk; i++)
- {
- float x = Mathf.Cos(i/Mathf.Rad2Deg) * Range,y = Mathf.Sin(i/Mathf.Rad2Deg) * Range;
- RaycastHit2D hit = Physics2D.Raycast(transform.position,new Vector2(x,y),Range);
- if(hit.collider != null)
- {
- hitted[i] = hit.point;
- /*test[i] = hit.transform.position - (hit.collider.bounds.size / 2);
- test[i] = hit.transform.position + (hit.collider.bounds.size / 2);
- test[i] = hit.transform.position + (new Vector3(hit.collider.bounds.size.x/2,-hit.collider.bounds.size.y / 2,0));
- test[i] = hit.transform.position + (new Vector3(-hit.collider.bounds.size.x/2,hit.collider.bounds.size.y / 2,0));*/
- }
- else
- {
- hitted[i] = new Vector3(0,0,0);
- }
- }
- }
- else
- {
- for(int i = 0;i<gk;i++)
- {
- hitted[i] = new Vector3(0,0,0);
- }
- }
- }
- void OnDrawGizmos()
- {
- for(int i = 0;i<gk;i++)
- {
- float x = transform.position.x + Mathf.Cos(i/Mathf.Rad2Deg)* Range,y = transform.position.y + Mathf.Sin(i/Mathf.Rad2Deg) * Range;
- if(hitted[i] != (new Vector3(0,0,0)))
- {
- Gizmos.color = Color.white;
- Gizmos.DrawLine(transform.position,hitted[i]);
- Gizmos.color = Color.red;
- Gizmos.DrawSphere(hitted[i],0.05f);
- }
- else
- {
- Gizmos.color = Color.white;
- Gizmos.DrawLine(transform.position,new Vector2(x,y));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement