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 /
This question was closed Jul 03, 2018 at 05:19 PM by DJGhostViper for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DJGhostViper · Jul 02, 2018 at 08:03 PM · transformworldspacelocationline renderer

Line renderer location problem

Im having a problem using Line Renderers on one of my unit gameobjects. When using World space it fires correctly at an enemy gameobject but the line renderer is at an odd position in the world (Picture unitusingworldspace). Without using world space the Line renderer is in the correct location at the tip of the gun (Picture unitnotusingworldspace) but when playing the game the line renderer is not showing up in the correct place at the tip of the gun anymore. How can I fix this?

unitnotusingworldspace.png (96.8 kB)
unitusingworldspace.png (97.2 kB)
Comment
Add comment · Show 6
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 hexagonius · Jul 02, 2018 at 08:17 PM 0
Share

I only see a red "something", what am I supposed to see. The LineRenderer Component is turned off ins$$anonymous$$d of on. To what does the position of the gizmo correspond? The difference in position is weird considering the same position values in the inspector. How is the gizmo configured? Center/ Pivot, Global/ Local?

avatar image DJGhostViper hexagonius · Jul 02, 2018 at 09:36 PM 0
Share

Ah, by changing the Gizmo configuration I have removed the weird offset by changing the gizmo center option to pivot, local. Now the unit still uses worldspace but the offset is over the unit. Im not sure if I will run into problems when using worldspace on the line renderer though. Thank you for mentioning the gizmo configuration, I would have never noticed that @hexagonis

avatar image NoDumbQuestion · Jul 03, 2018 at 01:30 AM 0
Share

Did you change Position element 0 and 1 in script?

avatar image DJGhostViper · Jul 03, 2018 at 04:11 AM 0
Share

Yes inside a script the position of the gun is used as one location and the other position is the enemy Gameobject

The code is as follows for the position setup of the line renderer

 Lazer.SetPosition(0, gun.transform.position);
 Lazer.SerPosition(1, enemy.transform.position);
avatar image NoDumbQuestion DJGhostViper · Jul 03, 2018 at 04:31 AM 0
Share

I think when you use World space of LineRender. It will use Transform position. Which what it actually use is localTransform since LineRenderer is child of Gun.

I think you have to inverse Transform from local -> world space. Try it and see if it work

avatar image DJGhostViper NoDumbQuestion · Jul 03, 2018 at 05:18 PM 0
Share

This seemed to work thank you. Without having the "World space" box selected use the code below to allow the line renderer to shoot correctly:

 Vector3 GunPos = transform.InverseTransformPoint(Gun.transform.position);

  Lazer.SetPosition (0, GunPos);
 
 Vector3 EnemyPos = transform.InverseTransformPoint(chaseTarget.transform.position);

  Lazer.SetPosition (1, EnemyPos);

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

111 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 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

How to move two same Objects at the same place in different scenes? 1 Answer

How to set a sprite's location to another sprite based on RNG. 1 Answer

Convert terrain map coordinates (GetDetailLayer) into world position 0 Answers

transform.position is giving me local space 1 Answer

Is there an end to Unity world space? 3 Answers


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