public static void AddPosition(Vector3 position, Vector3 direction) { if (IsFiring) { return; } LineRenderer current = GetRenderer(); Ray ray = new Ray(position, direction); RaycastHit hitInfo; Physics.Raycast(ray, out hitInfo, 50); positions[current].Add(ray.origin); current.SetPosition(0, ray.origin); Vector3 endPoint = hitInfo.point == Vector3.zero ? ray.GetPoint(50) : hitInfo.point; if (hitInfo.collider == null) { positions[current].Add(ray.origin); current.SetPosition(1, endPoint); return; } PieceController ps = hitInfo.collider.gameObject.GetComponent <PieceController>(); float hitY = endPoint.y; endPoint = ps.transform.TransformPoint(0, 0, 0); endPoint.y = hitY; positions[current].Add(ray.origin); current.SetPosition(1, endPoint); ps.LaserHit(hitInfo.point, hitInfo.normal); }