You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
545 B

using UnityEngine;
using System.Collections;
public class MagnetLaser : MonoBehaviour {
private LineRenderer lr;
// Use this for initialization
void Start () {
lr = GetComponent<LineRenderer> ();
}
// Update is called once per frame
void Update () {
// Magnet Laser Collision
RaycastHit hit;
if (Physics.Raycast (transform.position, transform.forward, out hit)) {
if(hit.collider){
lr.SetPosition(1,new Vector3(0,0,hit.distance));
}
else{
lr.SetPosition(1,new Vector3(0,0,100));
}
}
}
}