Answered many thanks for all your help everyone with special thanks to Louis with his single line of code answer
I am trying to find a Vector3 point along an angle projected from a Vector. This is the closest I have got and it realy misses the mark. I want to say ‘X’ degrees from forward facing, in plane ‘y’ project the ‘range’ and obtain the ‘point’ Vector3(x,y,z).
TO TRY AND HELP CLARIFY MY QUESTION
Sparkzbarca quote - ‘send a ray along an angle and get the point that is RANGE distance away from the origin of the ray?’. I would like the origin angle to be related to the original transforms forward facing. I would like to do it without altering existing transformations.
Please see alucardj picture for absolute clarity (many thanks alucardj ) I would like to find the vector at the green X.
public var scanSpeed : float = 10.0f;
public var range : float = 5.0f;
public var speed : float = 10.0f;
public var rotationSpeed : float = 10.0f;
private var shadowSelf : Transform;
function Start ()
{
shadowSelf = transform;
}
function Update ()
{
var rotAngle : Vector3;
//Show forward direction
Debug.DrawLine(shadowSelf.position, shadowSelf.forward * (range + 1), Color.green);
for (var x : int = 0; x < 90; x = x + 1)
{
// Sweep scan beam left n right 1-90 degrees
rotAngle = shadowSelf.TransformDirection(Quaternion.AngleAxis(x, Vector3.up).eulerAngles);
Debug.DrawLine(shadowSelf.position, rotAngle * range, Color.red);
rotAngle = shadowSelf.TransformDirection(Quaternion.AngleAxis(-x, Vector3.up).eulerAngles);
Debug.DrawLine(shadowSelf.position, rotAngle * range, Color.magenta);
DebugPrintOut(rotAngle, "rotAngle");
}
}
function DebugPrintOut(vec3 : Vector3, prnStr : String)
{
Debug.Log(prnStr + " = Vector3(x-" + vec3.x + ",y-" + vec3.y + ",z-" + vec3.z + ")");
}