Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

I hate unity... linerenderer issues...

Discussion in 'Editor & General Support' started by Unity-Artcraft, Feb 22, 2020.

  1. Unity-Artcraft

    Unity-Artcraft

    Joined:
    Jul 28, 2018
    Posts:
    85
    Why is it so damn f*%$§"%§ difficult to be consistent???
    Linerenderer from a duplicated prefab, one of them hits the target, the other one not....why???
    lr.SetPosition(0, transform.position);
    lr.SetPosition(1, target.transform.position);



     
    Last edited: Feb 22, 2020
  2. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    358
    Show us the start and end point for both LinerRnderers so we know what is going on!
     
  3. Unity-Artcraft

    Unity-Artcraft

    Joined:
    Jul 28, 2018
    Posts:
    85
    lr.SetPosition(0, transform.position);
    lr.SetPosition(1, target.transform.position);

    there is no both, it's a prefab, they use both the same script. And both GameObjects are at the exact the same location.
     
  4. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    358
    We need to see the numeric positions that are in the inspector for each! Obviously there is something else going on. ;-) We really need to see the rest of your script.

    Also, if this has anything to do with it: note that your script, note that the Cube transform property is empty - you know that Prefabs do not retain references to such objects. You have to repopulate them after the instance of the prefab is created...
     
  5. Kragh

    Kragh

    Joined:
    Jan 22, 2008
    Posts:
    656
    I have used LineRenderer more times than I can count. And I want to make a prediction: Whatever is wrong, it is not Unity's fault. When this is fixed, you will think: "Ahhh, ofcourse. How stupid of me"
    That is my prediction. NEVER had LineRenderer fail on this, the most basic of usages.

    Do you move the object after setting these values? This not a reference to the position, it is just a transfer of the values. So you would have to update the LineRenderer positions, if you made changes to the transform positions.
     
    Gordon_G likes this.
  6. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Are you moving the object after setting those values?
     
    Joe-Censored likes this.