How to understand that CFrame is looking down? (in code)

Hello, guys. I’m making autogeneration for trees. But, as usual, I got some problems, for now with CFrames. I need to tilt them down (orientation only). I already can tilt them down, but it’s possible them to tilt up after some time.
image

So, I need get value, which will represent, how much CFrame direction is looking down, to prevent tilting up.
image

Can anyone give me some ideas, how to implement this down-look check?

im not sure if i understand exactly what youre looking for but to get a measure of how much a cframe is ‘looking down’ you can use the look vector of the cframe and dot product it with the negative y axis (0,-1,0). To be precise this will give the cosine of the angle measured between the look vector and the -y axis. to get the angle you would just use acos

local cosine = cf.lookVector:Dot(-Vector3.yAxis)
local angle = math.acos(cosine)

(where cf is the cframe of the tree or whatever)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.