# LineRenderer not working using Vuforia in Unity

So I'm trying to render a line that shows up when camera sees an image target and moves around with it. Very typical AR application. But my line renderer doesn't seem to show at all.

Here's the code:

using UnityEngine;
using System.Collections;

public class myLine : MonoBehaviour
{
// Creates a line renderer that follows a Sin() function
// and animates it.

public Color c1 = Color.yellow;
public Color c2 = Color.red;
public int lengthOfLineRenderer = 20;

void Start()
{
lineRenderer.widthMultiplier = 0.2f;
lineRenderer.positionCount = lengthOfLineRenderer;

// A simple 2 color gradient with a fixed alpha of 1.0f.
float alpha = 1.0f;
);
}

void Update()
{
LineRenderer lineRenderer = GetComponent<LineRenderer>();
var t = Time.time;
for (int i = 0; i < lengthOfLineRenderer; i++)
{
lineRenderer.SetPosition(i, new Vector3(i * 0.5f, Mathf.Sin(i + t), 0.0f));
}
}
}


and here's my set up:

I also tried attaching the script directly to the ImageTarget and nothing happened.

• I think the problem here is that the camera is moving around in the scene to match orientation with your image target. But what you want is for the camera to be fixed and have the 3D model move around to match the image target. Am I correct? If so, you need to select the camera and change the "World Center Mode" to....Camera, I believe. – Draco18s no longer trusts SE Jun 22 '17 at 20:09
• @Draco18s No i'm moving the camera around and have my target fixed. I want the line to show up on top of my image target, but it doesn't. – user86861 Jun 22 '17 at 20:23
• Check that your line is being draw in local coordinates, not world, especially if your image target isn't placed at the origin. You may also wish to scale the coordinates you're setting so that it's larger. – Draco18s no longer trusts SE Jun 22 '17 at 20:30
• @Draco18s It seems to renders on PC but not on my device. only shows a pink square instead of what it's supposed to show. – user86861 Jun 22 '17 at 21:46