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 CunningGrayFox · Jul 03, 2015 at 02:07 AM · raycastline rendererponglaserlaser beam

Bouncing Laser Beam

What I am trying to achieve is a segment of a laser beam that would bounce between two players in a pong style game.

The raycast-line renderer combination I have implemented from here creates a continuous line not a laser beam segment.

Does anyone know how I may achieve this segmented ray?

Comment
Add comment · Show 1
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 incorrect · Jul 03, 2015 at 02:17 AM 0
Share

Actually LineRenderer creates lines between points you define, so to make a 'beam' (with 'pew' sound, I hope? xD) you have to update line start and line end points of your beam each frame.

So yes, I know how you could achieve this, but I will not do coding ins$$anonymous$$d of you. :3 Though you can ask for advices and tips. ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by CunningGrayFox · Jul 04, 2015 at 01:22 AM

I'm going to post my own answer in the hopes that future readers can use this as a very simple solution to an issue that is highly over complicated by most developers. But first...

@incorrect: Your comment wasn't helpful and rather insulting. I'm a web dev for a Fortune 500, I can write my own C#/.NET code. I posted this question in an attempt to avoid not only reinventing the wheel but also to see if someone had a simpler solution for what seems to be a common usage of a laser beam in games. If, as a developer, you always have tunnel vision and focus on one thing you'll never see the possibilities of a better, cleaner, and more elegant solution. If, as a developer, you never pull from the collective wisdom of your peers you'll never have as much knowledge as they have collectively. Finally, your snide comment is useless because the simplest solution requires zero coding effort.

TL;DR Put a trail renderer on the "ball" that gets ping ponged around; remove its sprite and then just tweak the trail renderer to achieve the desired affect. Et Voila!

If you want a non-physics based solution you'll have to write a bit of code to get the Raycast, LineRenderer, and Reflection to work just right.

Comment
Add comment · Show 1 · 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 ksakins · Aug 17, 2016 at 06:58 PM 0
Share

I've been attempting to do the same thing, and have used the trail renderer. However I'm having issues making it look right, as it seems the trail renderer does not show immediately at the time when you instantiate your "ball", or whatever it is attached to.

For instance, if 'X' were the instantiation point and "|" is a collider on my player object, the trail starts showing a little late.

|X [gap here] ==========O

I need this:

|X===========O

Any thoughts? I can't move my instantiation point back, because I don't want my "ball" to collide with "|"

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

23 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

Related Questions

How do i scale a prefab laser to hit.distance 1 Answer

Shoot Laser 0 Answers

Printing Distance b/w two points using line renderer and Raycast 1 Answer

Get raycast direction from weapon 1 Answer

on mouseclick if raycast hit with same tag drawline. 2 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