- Home /
Question by
Stratc · May 30 at 10:09 PM ·
2d gamenot workingline drawing
How to Inverse a line
I have a line that goes to the mouse position to show the way you will go but when I try to inverse it so it looks as if your pulling it does not work I don't know what to try now
public void DrawLine()
{
//Putting the start of the line on player
startPos = transform.position;
startPos.z = 1;
lineRend.SetPosition(0, startPos);
if(!started)
{
//Putting both lines to player at the start
lineRend.SetPosition(1, startPos);
}
if (Input.GetMouseButton(0))
{
//Moving the end of the line to the mouse position
lineRend.enabled = true;
moveTo = Camera.main.ScreenToWorldPoint(Input.mousePosition);
moveTo.z = 1;
lineRend.SetPosition(1, moveTo);
}
if (Input.GetMouseButtonUp(0))
{
lineRend.SetPosition(1, startPos);
lineRend.enabled = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to create a line with a repeated sprite on 2d map between 2 points 1 Answer
2d racing play button not working 2 Answers
How to fix this error 2 Answers
Double Jump 1 Answer