If I want to draw a line straight in front of my game object I can do:
Gizmos.DrawRay(transform.position, transform.forward);
How do I draw a line 15 degrees on each side of this line at the same 10 unit distance?
If I want to draw a line straight in front of my game object I can do:
Gizmos.DrawRay(transform.position, transform.forward);
How do I draw a line 15 degrees on each side of this line at the same 10 unit distance?
May be cheezy, but you could rotate your object 15 degrees, DrawRay, then rotate -30 degrees, DrawRay, then rotate 15 to get back to original rotation.
Ok Think I got it. Create an empty object that you child to your player.
the this to the child object.
function Update(){
transform.Rotate(Vector3(0,2*Mathf.Cos(5*Time.time),0));
}
function OnDrawGizmosSelected () {
// Draws a 5 meter long red line in front of the object
Gizmos.color = Color.red;
var direction : Vector3 = transform.TransformDirection (Vector3.forward) * 5;
Gizmos.DrawRay (transform.position, direction);
}
It works for me at least.Now the ray is sweeping in fromt of the guy, you need to define the proper value to make 15 degrees.