I am trying to make an attack indicator. In order to do this I am using a linerenderer which follows a ray to detect collisions. The only problem is that the ray is casted along linerendere’s center and I want two rays going along its margins. Any advice?
assuming that your linerenderer direction is known as
Vector3 LR_Dir then your raycast should have origin and riection as follows:
Vector3 rightOrigin = LR_Origin_Position + Vector3.Cross(LR_Dir, Vector3.up).normalized * LR_width; Vector3 leftOrigin = LR_Origin_Position - Vector3.Cross(LR_Dir, Vector3.up).normalized * LR_width;
raycast direction should just be the same the linerenderers. To make that a bit more pretty you should first calculate the crossproduct so that you do not calculate that twice every time.
Let me know if that helped.