I’m trying to calculate the angle the triangle would have to rotate to face the circle based on the triangle’s position at (1, 1) and the circle’s position at (3, 3). For context, I want a hinge to rotate to face a player.

1 Like

`math.deg( math.atan2(targetpos.Y - trianglepos.Y, targetpos.X - trianglepos.X) )`

1 Like

```
local triangle = -- path to triangle
local pos1 = triangle.Position
local pos2 = -- target position
local cframe = CFrame.new(pos1,pos2) -- or CFrame.lookAt(pos1,pos2)
local x,y,z = cframe:ToOrientation()
triangle.CFrame = CFrame.new(pos1)*CFrame.Angles(0,y,0)
```

The above script is going to rotate said triangle so that is faces the player only is the Y plane, i.e there is not up/down/tilt rotation.

1 Like

Thanks. I managed to isolate the y value (so I could use it with a hinge constraint) by making a mock up of CFrame.Angles(). Probably could’ve just used CFrame.Angles().Y though, haha.

No problem, glad your issues are solved.

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