Question by
Speonight · Jun 24, 2018 at 01:05 PM ·
uibuttonlinerenderer
how can i get access to the line renderer elements or the size of the line in the z and change the collider size to the size of the laser(i am using a laser particle for this)/
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class laserPointer : MonoBehaviour { private LineRenderer laserP; private Vector3 name = new Vector3(0,0,3); private BoxCollider bc; // Use this for initialization void Start () { laserP = GetComponent(); bc = GetComponent(); }
// Update is called once per frame
void Update () {
laserP.SetPosition(0, transform.position);
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit))
{
if (hit.collider)
{
laserP.SetPosition(1, hit.point + name);
}
}
else {
laserP.SetPosition(1, transform.forward * 500);
}
bc.size = new Vector3(bc.size.x, bc.size.y, laserP.GetPosition * 5);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.transform.tag == "Button")
{
Debug.Log("gsdf");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Upgrade Weapon Stats on Different Script 0 Answers
Make UI button or Joystick Problem 1 Answer