- Home /
line renderer problem
i have created a line renderer and attached to the cube when mouse moves around the screen the line renderer should move around the mouse i have attached the scripts to the cube while i am trying to move mouse it line renderer is not moving i have attached my sample code
var cube1 : Transform; var m_pos : Vector3; //mouse postion var line : LineRenderer ; //line renderer
function Update()
{
var lineRenderer : LineRenderer = GetComponent(LineRenderer);
var ray = camera.main.ScreenPointToRay(Input.mousePosition);
var pos : Vector3 = ray.GetPoint(10);
m_pos = pos;
Debug.Log(m_pos);
if(Physics.Raycast(ray))
{
first(); //function
}
}
function first()
{
line.SetVertexCount(2);
var pos1 : Vector3 = cube1.transform.position;
var pos2 : Vector3 = m_pos;
line.SetPosition(0,pos1);
line.SetPosition(1,pos2);
}
line render is not moving around the mouse it is staying in fixed postion without any change i have coyped cube transform postion into line renderer postion then also it is not working
Your answer
Follow this Question
Related Questions
line renderer question 1 Answer
split/line through my model? 1 Answer
How do I make a collidable trail? 1 Answer
How to check of a line renderer collides with ground ? 1 Answer
Help with SlingShot trajectory... 1 Answer