- Home /
Magicka-like beams. How to approach this.
Hello guys.
I'm making a Magicka: Wizard Wars clone in Unity just for fun. So far I managed to plan and code most of the spell types (mines, storms, projectiles, etc...), but there's one that I have no idea how to approach: beams. At first I thought a simple raycast would be enough, but the problem is that beams collide with eachother too so you can deflect beams with other beams. Do you guys have any idea how can I code the beams? Just to clarify, I'm not asking you to do the work, I just want some ideas on how to approach this because I keep thinking about it and I can't figure it out. Maybe there's some physics function I don't know about or something. Any help will be much appreciated.
Thank you for your time :)
Sorry, I phrased that really badly. I need the beams to collide with eachother and I can't do that with a raycast, because they only hit colliders not other raycasts.
The only way I found that works decently is creating a procedural collider the length of the beam. I just wanna know if there's a better way.
Thanks for your reply :)
You could do it purely by code using some mathematic calculations to see if thwo rays overlap. Otherwise, I think it'd be easiest to indeed use temporary mesh colliders/triggers.
Would it be possible to just put a sphere collider at the end of the beam? Something like a DBZ $$anonymous$$amehameha Wave? Just fake the other part of the beam? Or, do they need to intersect as well as collide head on?
The sphere at the end of the beam wouldn't work. I need something to detect where the beams cross.
It looks like I have to do it with the collider. I don't think I know enough maths to do it just purely mathematically.
Thanks for the suggestions, guys. I really appreciate you taking the time to answer.
Answer by vulpineblazeyt · Aug 14, 2015 at 07:25 PM
I was able to make a laser beam by using this tutorial:
... and then giving the center piece of a laser collidable properties.
Change the sprite so something more magic-relevant and this should work.
Your answer
![](https://koobas.hobune.stream/wayback/20220611235751im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
LineRenderer (Laser Beam) is not following the ray it's going on the wrong direction when reflecting 1 Answer
camera.ScreenPointToRay always has same origin... 1 Answer
Printing Distance b/w two points using line renderer and Raycast 1 Answer
How can I can I cast a ray from a gameobject? 1 Answer
Raytracing through an octree? 0 Answers