Attention |
Topic was automatically imported from the old Question2Answer platform. | |

Asked By |
enceladus |

Hello! This is my first post on here so I apologize if this is the wrong place to ask this or I’ve omitted any important information.

I have a 3D third-person camera setup with a camera, a spring arm and a spatial I’ve designated **camera_pivot**. what I’m trying to do is create a camera system where when you look down, the camera pivot rotates along the X axis to make the camera move upward to get a bird’s eye view, but when you look up, the pivot remains stationary and only the camera rotates. Put more simply, the camera moves up when you look down, but it doesn’t move down when you look up.

To achieve this, I’ve tried using an if statement so that if the camera’s X rotation is at 0 degrees or below, only the camera rotates, but if it’s above 0, the camera pivot rotates.

```
var min_camera_rot : float = 0
var max_camera_rot : float = 90
var min_pivot_rot : float = -45
var max_pivot_rot : float = 0
#(Irrelevant code omitted)
func _input(event):
if event is InputEventMouseMotion:
rotation_degrees.y -= event.relative.x * mouse_sensitivity
if camera.rotation_degrees.x <= 0:
camera.rotation_degrees.x -= event.relative.y * mouse_sensitivity
camera.rotation_degrees.x = clamp(camera.rotation_degrees.x, min_camera_rot, max_camera_rot)
else:
camera_pivot.rotation_degrees.x -= event.relative.y * mouse_sensitivity
camera_pivot.rotation_degrees.x = clamp(camera_pivot.rotation_degrees.x, min_pivot_rot, max_pivot_rot)
```

But this results in the camera pivot rotating, but clamping at 0 degrees and not handing rotation off to the camera like it’s supposed to.

I’ve also considered making the if statement check whether **camera** is at a higher global y position than **camera_pivot**, but I couldn’t get that to work either.