Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawLazer()
- {
- Vector2 origin = new Vector2(firePoint.transform.position.x, firePoint.transform.position.y);
- Vector2 direction = transform.TransformDirection(Vector2.up);
- RaycastHit2D hit = Physics2D.Raycast(origin, direction, 10f);
- Debug.DrawLine(origin, direction *10000, Color.black);
- if (hit)
- {
- Debug.Log("Hit: " + hit.collider.name);
- var whatWeHit = new Vector2(hit.transform.position.x, hit.transform.position.y);
- var offset = whatWeHit + hit.point;
- offset.y = 0;
- RaycastHit2D hit2 = Physics2D.Raycast(offset, Vector3.Reflect(direction, hit.normal) * -10000);
- if (hit2)
- {
- Debug.DrawLine(offset, -Vector3.Reflect(direction, hit.normal) * -10000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement