How would I accomplish this?

Lets say I have an attachment like this:

Notice how the golden / orange arrow is pointing straight.

How can I make it so the golden / orange arrow points the same way as the surface under it using a script?

Here is an image to show what i’m trying to accomplish:

Notice, how the golden / orange arrow points in the same direction as the surface under it. How would I accomplish this using a script?

2 Likes

You could get the angle of the slope by using some math:

arctan(opposite/adjacent) would be the formula you’re after. Where opposite and adjacent would be the length and height of the triangle/slope.

After that you can take that angle and then apply to the rotation of the cube so that it matches the slope.

3 Likes

If you cast a ray from the part to the slope, you can get the surface normal of that slope. From there, it should be pretty simple to make the part’s angle match it.

1 Like