Laser Scripting

Hi guys,

I’m doing a laser, as part of a game, that I’m doing. I tried a few techniques, like line renderer and cylinder, for rendering the laser, but, they can’t be used, as both creates some problems, later on, in the concept that, I have.
So, I left both those techniques and started thinking about something new, and here’s my plan :

Create a sphere, translate it, in forward direction. Whenever, it enters, a trigger, it will rotate, by 90 degrees. I’m having 2 problems, while using this technique :

1)The sphere has to keep on, hitting and reflecting from, within the collider barriers, and my problem is, Sometimes, sphere is let, through the collider, and sometimes, sphere collides with the barriers perfectly.

  1. Secondly, I need values, to be perfect. Whereever the sphere hits, I need to add that position, to an array, for later use. But, for same setting, each time physics, acts differently, and returns me, different points, with difference, of, like 0.045…and like that.

Although my 2nd question, I could’ve avoided here, but, my main problem is my first question.
Please help, guys,

Thanks.

Have you tried using raycasts?

Try observing the sphere hitting the collider pausing Unity and hiting the Step button.

If the sphere is moving very fast, it can pass through the collider because it is in front of it on the current frame and then behind it on the next frame.

This can be solved with raycasts and someone already wrote about it on this forum, but I can’t seem to find it.

Ok, thanks guys…But, I’ve used raycast before, and makes things a bit difficult with my concept…

And I’m not having that go through collider, problem now, I must’ve done something :roll: …, How can I rotate a transform, by 45 degrees, every time, I hit the inner walls. I’ve used Vector3.reflect, but, that calculates direction itself. How can I reflect it by 45 degrees?

Could the particle system be used to render a makeshift laser?