Hello Everyone,
Im in the middle of a problem that is taking me some time. I
m currently developing a 2d topview game.
I`ve predefined 2 points of a line by using raycasthit to know when user set mouse down and up. Now my mind is blank to what can I do to raycast a line( as i have already done with line renderer ) to get all objects that collides with the line.
I thougth of using some objects with collider and instantiate within the line, but it`s not a satisfactory resolution.
Here is the code part that I`ve writed.
float distance = Vector3.Distance(initPos,finalPos);
RaycastHit hi;
Ray ra = new Ray(initPos,finalPos);
if (Physics.Raycast (ra, out hi,distance)){
if(hi.collider.tag=="Enemy"){
Destroy(hi.collider.gameObject);
}
}
Thanks for reading this, now please help me! ^^