Z
Z
Zimaell2020-06-28 14:19:27
Unity
Zimaell, 2020-06-28 14:19:27

How to hold a beautiful beam?

Previously, I already asked how to make a laser beam, rummaged through various examples, I couldn’t really figure it out.
Here's what I have at the moment - there is a gun that has a tower (initial coordinate), there is an enemy (end coordinate), I have these two coordinates calculated normally, and that I build a beam like this

spoiler
void Start(){
  towerHead = transform.Find("Head");
  GameObject lineObj = new GameObject("LineObj");
  lineRenderer = lineObj.AddComponent<LineRenderer>();
  }
  
void Update(){
  lineRenderer.SetPosition(0,towerHead.transform.position);
  lineRenderer.SetPosition(1,enemy.transform.position);
  .............

That is, a default lineRenderer is created and drawn from the tower to the target, and it turns out not a ray, but some kind of pink rectangle, how to set it up?
I tried to create a line element and make a prebuff out of it, but when using it, it is not visible at all, and there are no bends, as if it is invisible ...
I still can’t understand how it works and I can’t find sensible examples where it would be clearly explained what and how. ..

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question