Ok, i’ve got the following script:
using UnityEngine;
using System.Collections;
public class playerRayCast : MonoBehaviour {
Vector3 touchPosition;
void Start () {
this.gameObject.AddComponent<LineRenderer> ();
this.gameObject.GetComponent<LineRenderer> ().SetWidth (0.01f, 0.01f);
}
void Update () {
if (Input.GetMouseButton (1)) {
touchPosition = Input.mousePosition;
this.gameObject.GetComponent<LineRenderer>().SetPosition (0, this.transform.position);
this.gameObject.GetComponent<LineRenderer>().SetPosition (1, touchPosition);
this.gameObject.GetComponent<LineRenderer>().SetColors (Color.white, Color.white);
}
}
}
The script is attached to a game object which is on the left hand side of the screen space. When I right click it generates the line but the line is NOT going to where the mouse position is…
Any ideas?