Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Wabo · Dec 08, 2012 at 05:11 PM · raycastline renderer

Line Renderer Rotation is off.

Hey guys, I'm currently working on a school project that is nearly finished. This game focusses on using lightsbeams to solve puzzles. However there's one little problem. I'm using raycasts to determine if this lightsource hits a receiver, and its functioning very well. However, on the visual part, I'm using Line Renderers to visualize a beam for the player. Whenever I rotate the parent object ( 1 Sphere, with Children: ParticleSystem, Raycaster, Line Renderer) everything rotates in the right direction except for the Line Renderer. The Line Renderer rotates with some sort of anchor point which messes up the beam direction. Pics below:

http://imgur.com/O9Rtw, http://imgur.com/GWFy2, http://imgur.com/H6UwY (Raycast not included in the pictures, but the particles in these pictures matches the raycast perfectly)

I don't know what is causing this problem, but as far as I know its not the rotation. Because everytime I rotate the orb in a 90, 180, 270 or 360 degrees way, the Line Renderer is matching the raycast perfectly, except for the degrees between these 4 keypoints.

I've been searching both the scripting reference and these forums for solutions or similar problems, but I can't find anybody with a similar problem. I've been detaching the Line Renderer object off of the parent object and updating it's rotation via another script, but that won't work either (same problem).

Could anybody help me out please? :)

Below is the code I used for creating the Raycast and the Line Renderer, and which way they are supposed to point towards.

         RaycastHit hit;
         Vector3 forward = transform.TransformDirection(Vector3.forward);
 
         
         Debug.DrawRay(transform.position, transform.forward * rayLength, raycastColor);
         
         int layerMask = 1 << 8;
         layerMask = ~layerMask;
         
         if(Physics.Raycast(transform.position, forward, out hit, rayLength, layerMask))
         {    
             if(lineRenderer != null)
             {
                 lineRenderer.SetColors(c1, c2);
 
                 if(hit.collider)
                 {
                     lineRenderer.SetPosition(1, Vector3.forward * hit.distance);
                 } else {
                     lineRenderer.SetPosition(1, Vector3.forward  * 5000f);
                 }
             }
         }
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

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

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

Related Questions

on mouseclick if raycast hit with same tag drawline. 2 Answers

Line Renderer Disappears 1 Answer

Updating line positions with reflections 1 Answer

Aim Line (Line Renderer) not showing in 2D shooter 2 Answers

Bouncing Laser Beam 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