I am trying to make an electricity system, where it is given the start and end points, and it works out a random sequence of points in the rough direction of the end point. These points are set as vertices on a line renderer, and it should end up joining up as a bolt of electricity. My problem is that it needs to move 'forward' from start to end. The easy solution is that the electricity comes from a game object, which is set to
LookAt the end point. Then, every time it sets a 'nextPoint', it adds to the transform.forward.
nextPoint = new Vector3 ((startingPoint.forward.x + divergence.x), (startingPoint.forward.y + divergence.y), distance);
divergence is a
Vector3 containing a random increase on the x and y axis, and 1 on the z axis.
This works, in a way. The problem is that it then assumes these are world-space coordinates. So the line will go from starting point, to (eg. 0.3, 0.75, 1), and then back to the end point. I can't find a localToWorld conversion for a vector though, so I am not sure how to get the transform.forward + whatever, converted from local to world space.