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

  1. using UnityEngine;
  2. using System.Collections;
  3. public class MagnetLaser : MonoBehaviour {
  4. private LineRenderer lr;
  5. // Use this for initialization
  6. void Start () {
  7. lr = GetComponent<LineRenderer> ();
  8. }
  9. // Update is called once per frame
  10. void Update () {
  11. // Magnet Laser Collision
  12. RaycastHit hit;
  13. if (Physics.Raycast (transform.position, transform.forward, out hit)) {
  14. if(hit.collider){
  15. lr.SetPosition(1,new Vector3(0,0,hit.distance));
  16. }
  17. else{
  18. lr.SetPosition(1,new Vector3(0,0,100));
  19. }
  20. }
  21. }
  22. }