# JS to C# conversion Problem

I was wanting to convert a js script over to C# and for the most part its done but I have one line giving me problems please help.

``````using UnityEngine;
using System.Collections;

public class Lightning : MonoBehaviour {

public GameObject target;
public LineRenderer LR;
public double arcLength = 2.0;
public double arcVariation = 2.0;
public double inaccuracy = 1.0;

void Update()
{

Vector3 lastPoint = transform.position;

int i = 1;

LR.SetPosition(0, transform.position);//make the origin of the LR the same as the transform
while (Vector3.Distance(target.transform.position, lastPoint) >.5)
{//was the last arc not touching the target?
LR.SetVertexCount(i + 1);//then we need a new vertex in our line renderer
public fwd = target.transform.position - lastPoint;//gives the direction to our target from the end of the last arc20.
fwd.Normalize();//makes the direction to scale
fwd = Randomize(fwd, inaccuracy);//we don't want a straight line to the target though
fwd *= Random.Range(arcLength * arcVariation, arcLength);//nature is never too uniform
fwd += lastPoint;//point + distance * direction = new point. this is where our new arc ends
LR.SetPosition(i, fwd);//this tells the line renderer where to draw to25.
i++;
lastPoint = fwd;//so we know where we are starting from for the next arc
}
}
``````

The line with the problem is

``````public fwd = target.transform.position - lastPoint;//gives the direction to our target from the end of the last arc20.
``````

If needed I can post the js version I was working from.

Try:

``````Public Vector3 fwd;

//code

fwd = target.transform.position - lastPoint;//gives the direction to our target from the end of the last arc20.
``````

Declare in the top of the script then remove the public from the fwd at Update function