Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Betmans · Jun 25, 2017 at 03:28 PM · transformposition

Line renderer transform position problem

Hello! I have this issue, that while using line renderer, the positioning of the begin position and end position is not even near where it should be. I use the following script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class ProceduralLightning : MonoBehaviour {
 
     private LineRenderer lRend;
     public GameObject target;
 
     public Vector3[] positions;
 
     GameObject enemy;
 
     void Start () {
         lRend = GetComponent<LineRenderer> ();
     }
 
     void Update () {
 
         RaycastHit2D seeingObject = Physics2D.Raycast(new Vector2(transform.position.x + 2, transform.position.y), Vector2.right);
 
         if (seeingObject.collider != null) {
             if (seeingObject.collider.gameObject.tag == "Enemy") {
                 target = seeingObject.collider.gameObject;
             }
         } else { target = null; }
 
         if (target == null) {
             lRend.numPositions = 0;
         }
 
         if (Input.GetKey (KeyCode.Space)) {
             if (target != null) {
                 Vector3[] positions = new Vector3[7];
                 positions [0] = GameObject.FindGameObjectWithTag ("Player").gameObject.transform.position;
                 positions [1] = new Vector3 (Random.Range (0f, 1f), Random.Range (0f, 1f), 0);
                 positions [2] = new Vector3 (Random.Range (0f, 1f), Random.Range (0f, 1f), 0);
                 positions [3] = new Vector3 (Random.Range (0f, 1f), Random.Range (0f, 1f), 0);
                 positions [4] = new Vector3 (Random.Range (0f, 1f), Random.Range (0f, 1f), 0);
                 positions [5] = new Vector3 (Random.Range (0f, 1f), Random.Range (0f, 1f), 0);
                 positions [6] = target.transform.position;
 
                 lRend.numPositions = positions.Length;
                 lRend.SetPositions (positions);
             }
         }
     }
 }
 

so it should connet the lines between 2 objects in the scene, but instead of doing that, it offsets both ends somewhere completely offscreen.

I notice that it sort of resembles the required positions, but when moving my player, the beginning line, moves the same way, but much faster, creating this offset. I ust dont understand.

these are the begin,end positions:

alt text

capture.jpg (26.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by Betmans · Jun 26, 2017 at 07:35 AM

I am really sorry for asking such a dumb question, but if for some odd reason anyone else is as dumb as me, just uncheck "Use World Space".

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Crump05 · Aug 31, 2020 at 12:03 PM 0
Share

Saved my day thanks mannnn!

avatar image jbhere · Feb 03, 2021 at 07:01 AM 0
Share

thanks so muchhhhh man

avatar image XYHC · Feb 07 at 04:17 AM 0
Share

Thanks for leaving this post up & giving the solution!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

84 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

can't use camera position in equasion, help! 2 Answers

Grab position from instantiated object 1 Answer

How to make custom handles take gameobject position offset into account? 0 Answers

How to make object follow touch position?Pls Help 0 Answers

Change position of camera on scene load? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges