I created a cube with meshfilter, boxcollider, rigidbody(in 2D platform) in unity. It creates a raycast towards each of the vertices in the scene(platforms, boxes and anything having box collider with it).
But, I am having a problem as how to fill a color between any two raycast I created.
My game scene:-
My script:-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lights : MonoBehaviour
{
public GameObject[] sceneObjects;
public float offset = 0.01f;
RaycastHit hit, hit2;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Vector3 myPos = this.transform.position;
for (int i = 0 ; i< sceneObjects.Length; i++){
Vector3[] mesh = sceneObjects[i].GetComponent <MeshFilter>().mesh.vertices;
for (int j=0; j<mesh.Length; j++){
Vector3 vertiLoc = sceneObjects[i].transform.localToWorldMatrix.MultiplyPoint3x4 (mesh[j]);
Physics.Raycast (myPos, new Vector2 (myPos.x - vertiLoc.x - offset, myPos.y - vertiLoc.y - offset),out hit, 100);
Physics.Raycast (myPos, new Vector2 (myPos.x + vertiLoc.x + offset, myPos.y + vertiLoc.y + offset),out hit2, 100);
Debug.DrawLine (myPos, hit.point, Color.green);
Debug.DrawLine (myPos, hit2.point, Color.blue);
Debug.Log (vertiLoc);
}
}
}
}