- Home /
Draw lines with Vectrosity in the direction transform.forward
So I know there is SetRay and it would be perfect if I could set the width of the line but I can't. This is what I have now. It works if I don't rotate my character but as soon as I do it messes up.
var shootForward = Vector3(transform.position.x, transform.position.y, transform.position.z + 50);
shootForward = transform.TransformDirection(shootForward);
var origin = transform.position;
linePoints = [ origin, shootForward ];
laserLine = VectorLine(lineNumber.ToString(), linePoints, Color.yellow, null, 2.0);
laserLine.Draw3D();
You could just cast a ray and draw the line to whatever point it hit; something like this:
RaycastHit hit;
Physics.Raycast(new Ray(transform.position, transform.forward), out hit, float.PositiveInfinity);
linePoints = [transform.position, hit.point];
laserLine = VectorLine(lineNumber.ToString(), linePoints, Color.yellow, null, 2.0);
laserLine.Draw3D();
Answer by Eric5h5 · May 05, 2013 at 05:09 AM
SetRay returns a VectorLine object, so you can call SetRay and then do what you want with the VectorLine afterward, including setting the width.
var myLine = VectorLine.SetRay(...
Then do what you want with myLine. See page 5 in the docs.
I cannot add the width without getting an error
var laserLine = VectorLine.SetRay3D(Color.yellow, transform.position, transform.forward *5);
You haven't tried setting the width in that code. Just use VectorLine.lineWidth. Also please read page 5 in the docs.
Thank you I think I got it. I just had to do this right? And yeah I've read the page 5. Still wasn't clear to me
laserLine.lineWidth = 10.0;
Your answer
Follow this Question
Related Questions
Move an object forward and not up? 1 Answer
Turn and Move Foward 1 Unit relative to Objects local direction 1 Answer
3D ellipse with Vectrosity 1 Answer
don't include vertical distance? 2 Answers