Changing Y based on Angle

So I’m trying to shoot these kunais in star formation like this 43e30b73af08df1942226e749a41976c
I just got the circle with star image on it and changed its coordinates to 0,0,0. I placed kunais on edges and got their PrimaryPart position. After that I just did this


It worked but only when I was shooting kunais directly to top or bot. Any time I changed angle they would mess up. Well that’s because as you can see in image Y coordinate always stays the same and I need to change it based on angle but I have no idea how.
Here’s a gif to get the better idea of what I’m talking about: https://gyazo.com/4ef73d2ae77b0e2fd0e54db0aeceb8a4

2 Likes

That’s a regular pentagon. A regular pentagon’s central angles are 72 degrees:

image

This should give you a hint on how to tackle this problem differently.

Yeah I know that. But how do I get angle between my camera and Mouse.hit.p. If I knew that I could do the rest

Inverse trig, but it depends which angle you want. Can you sketch a diagram for us?

I think i came up with something but I haven’t tested it yet.


For example if camera will be directly on top of my char. it will look like this. This way it’s easy, but if camera isn’t on top of my char triangle type changes. I guess if I can get distance between camera and my mouse. I’ll know all triangle sides and after that I’ll be able to calculate angles as well. I just need to look up mathematical formulas for that.

You only need to know two sides of a right triangle to be able to solve everything else. In your case, use tangent (tan(angle) = opposite/adjacent) to find the angle.

Yeah but it won’t be always right triangle. For example if my camera is behind my character then it will be different type.

If you know three sides of any triangle, you can solve for the angles with sine and cosine law.

(Cosine law to solve for the first angle).

1 Like

2602e5343a829892d72ef15bc06e5813
I guess this should help

1 Like