Hello,
I’m trying to draw a ray within my Gizmo, but I can’t seem to get it to go in the correct direction.
I basically have two GameObjects, called A and B. A is connected to B, and fires a Blue DrawLine from A to B. I want to also fire a smaller Green line from A, in the DIRECTION of B, but for it to only be a short line, and also offset to the left. This is to show the user that A is connected to B.
This is what I currently have:
The Upper Left is B, the Lower Right is A. A is connected to B (shown by the Blue Line).
I want to Green Line to be basically 180 degrees the other way, and offset a little so its not on-top of the Blue Line.
This is what I want:
How can I achieve this?
//this transform is _A
Gizmos.color = Color.green;
Vector3 dir = transform.TransformDirection(transform.position - _B.transform.position) * 0.5f;
Gizmos.DrawRay(transform.position, dir);
Gizmos.color = Color.light_blue;
Gizmos.DrawLine(transform.position, _B.transform.position);