The title is quite confusing but ill try my best to explain it. Basically, i’ve got a basic part with a size and a centre, and i have a direction that goes from the centre of the part and hits the border of a part… Okay i don’t even know how to explain it but i do have a picture of what i would want it to be like.
the red vectors here are the direction, and the blue dots are the resulting position i want. Sorry for the extremely poor explanation but i think that the image describes it better.
I’m not sure if I got what you meant, but if you add the correct combination of Size properties to a part’s Position property, you’ll find the exact points.
Keep in mind that Position property is the location of your pivot which is centered by default on parts.
Example, suppose P is the center of this part (Position property)
On 3D space this would give the position of the lower right corner but on the middle of the part in Z axis, you can also add +/- z/2 to find the upper and lower right corners with respect to the z axis.
There are some things to look out for when rotation is involved. If this part was rotated 45 degrees,
As you can see, p’ is no longer the lower right corner of this part, even though Size or Position of the part did not change. Both of the properties are just numbers, so with the previous calculations, while giving the same answer, this time the answer would be wrong.
This is where usage of the CFrame property is required. I’ll leave that part to you for now, but if this answered your first question and you have a hard time understanding CFrames after your own research, I’ll write another reply explaining the same thing with CFrames.
I think i worded my questions weirdly. I’ll try to make a 3d version of what i would wanna make to maybe clear up some confusion. Also, i understand cframes pretty decently so i don’t think i wouldn’t understand a solution using them. Thanks for the reply!
Is the specific point predetermined? Meaning you give it an angle/input and it finds the border of the part. For example you call a function with the given angle myFunction(35) (35 is the degrees or whichever input that you give it)
No, this is not on a surfaceGui, this is on a basic block part, but yeah, you give it a direction and it finds you the border of the part that’s in that direction (so predetermined)
alright, i’ve made a little model to explain how i would want it to work. Pretend the green, white and yellow parts are vectors and the big blue part is the part that we’re gonna find the borders of. The “vectors” start from the centre of the part and the red dots here are the result im trying to find (their position). The red lay on just the part’s border and are a continuation (or whatever i should call it) of the vectors.
If you are going to do this from a mathematical standpoint I think it’s going to be difficult (Well for me atleast ). You can use @Aerodymier’s solution but from what I can see, this only gets the corners of the part.
Now if you want to do it the lazy way. I will just use raycast and call it a day lol. However the raycast might go through the box and not hit the edge since it’s inside the part. An easy fix for this is probably just to get the lookvector of wherever the direction you want it and inverse it( meaning shoot a raycast towards the box/towards itself so you can get the edges)
Just throw in a raycast params so that it guarantees it always hitting the box.