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 Mark981 · Oct 23, 2012 at 05:40 PM · playerlaser

Line Renderer Collision Detection.

Hi,how can i make line renderer detects collisions on its way (Player) and when collision is detected then print("player detected")

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

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by greenshadow · May 12, 2013 at 06:56 AM

I think you're looking for something like this (C#)...

 RaycastHit hit;
 if (Physics.Raycast (lineStartPosition, lineEndPosition - lineStartPosition, out hit)) {
     switch(hit.transform.gameObject.tag)
     {
         case "Player":
             //Output message
             print("player detected");
         break;
     }
 }
Comment
Add comment · Show 2 · 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 Marks981 · May 12, 2013 at 06:11 PM 0
Share

Hey greenshadow,nice script,looks like it should work,but the script is wrong written and full of errors,i mean it dont works,can you please write script correctly?

avatar image greenshadow · May 12, 2013 at 06:56 PM 0
Share

$$anonymous$$ark, the script does work, I use it in a game I am making right now. The only thing is that "lineStartPosition" and "lineEndPosition" are Vector3 variables, but not variables that are defined in Unity namespace. You must replace them with your own Vector3s that you used to set your Line Renderer positions with.

$$anonymous$$aybe you can paste in a snippet of your current code for the Line Renderer, and I can show you from there.

avatar image
1

Answer by DaveA · Oct 23, 2012 at 06:03 PM

You may need to Raycast each line segment yourself. I hope there is a better answer

Comment
Add comment · Show 2 · 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 DaveA · Oct 23, 2012 at 08:52 PM 0
Share

Yes. You do Raycasting in scripts.

avatar image Mark981 · Oct 31, 2012 at 10:36 AM 0
Share

Anyway that was the worst answer ever.

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

12 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

Related Questions

Multiple Cars not working 1 Answer

Raycast Destroys player. 1 Answer

Player destroys when he touches particle effect. 1 Answer

GUI cale and position according to the actual screen resolution. 1 Answer

C# Reload Script 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