How to create an arcing effect using rays? (repost)

I’m not sure what you mean by that.
I did show a lot of code that would be the backbone for what I thought you were asking for.
The code I showed was the hard part of this entire thing.

I also don’t understand your usage of “raycast”. Raycast refers to a very specific thing. It refers to when you are performing a geometry query; looking to see if any parts intersect with a straight line. And it is always a straight line. If you want a “curved raycast”, you would need to do multiple raycasts that form the curve you want. And that can be achived using the code I’ve showed before.

The code I showed is basically generating an array of points. So you could use those to create a series of raycasts.

Otherwise, if you use the code for somthing that is purely an effect, then that is not a raycast.

Just to be clear, the code I’ve shown already is like 95% of your question. You are free to alter certain things in that code to fit what you are trying to do.
The things that matter the most to you are:
“startPos”, “endPos”, “xOffset”, “yOffset”.
Also, “forward + rightShift + upShift” is the position of each “point” on the lightning bolt.

Whether you are trying to make somthing functional or visual with a lightning shape, this code is the backbone. It’s just a matter of adjusting things to fit your code.

1 Like

Oh my… I really do suck at explaining things. Well I’ll try to re-explain it one more time.

The middle part casts a ray until it hits something. Right, that’s how raycasts work. You could refer to it as: middle part Position is A and raycast.Position is B.

So it casts a ray in a random direction, and then on that ray, I want to create a lighting effect, not a very complex one. Then, divide the ray distance (distance between A and B) into segments, and on those segments create triangles using sine/cosine.

Based on the distance between A and B (ray.Distance), I want the segments to be the same size every time, so it doesn’t strech the lighting arc…

Hope you understood this time, and sorry if anything wasn’t clear.

I think I understand. The only thing is that I have to assume “middle part” really means “starting part” because in a typical raycast, there is no “middle thing”. It’s just a start and an end, which you know. Otherwise, I would still be confused. So I assume that’s what you mean.

The ray starts at some part, and goes off in any direction, but then stops, so it has a length.

You then want to take the ray and divide it up into segments that are all the same length.
So, this dividing up of a ray is indeed being done in the code I showed you thus far, that is what the for loop is doing. The only thing you have to chance is the “important bits” of the code.
So like you said, the ray starts at some part, that would be “startPos” in my code. Then you said the other end of the raycast would be “raycast.Position”, that would be “endPos” in my code. It’s 100% up to you to change how the values are supplied to that script in order to make it work the way you want it to work. It’s 100% flexible.

But then you say you want to create triangles using sine/cosine.
Which, again, I can understand what you are saying here. But that is a bit confusing condering this is Roblox. And I am also having a hard time visualising in my mind what that would exactly look like.
Keep in mind, I am still using your original image to get an idea of the effect you are trying to make.

I’m trying to imagine that the segments would be made of wedge parts maybe?
That’s what I am seeing in my mind at least.

But to be clear, I think this new explanation is a lot better at laying out what you are trying to do.
I think it’s just me personally having trouble being 100% sure of the effect.
Because typically, people might just use regular rectangle parts for the segments, or use a bunch of beam objects. But it sounds like you doing somthing very different.

1 Like

This is what I am trying to achieve. (those lightings coming out of the ball also sorry my computer is laggy)