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.
In mathematics, the trigonometric functions (also called circular functions, angle functions or goniometric functions) are real functions which relate an angle of a right-angled triangle to ratios of two side lengths. They are widely used in all sciences that are related to geometry, such as navigation, solid mechanics, celestial mechanics, geodesy, and many others. They are among the simplest periodic functions, and as such are also widely used for studying periodic phenomena through Fouri The...
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