camera: added camera zooming
This commit is contained in:
parent
c78368c89e
commit
4e8b397948
2 changed files with 20 additions and 0 deletions
|
|
@ -7,6 +7,9 @@ var locked_mouse_positon = Vector2(0,0)
|
|||
var mouse_locked = false
|
||||
var mouse_x_velocity = 0
|
||||
var mouse_y_velocity = 0
|
||||
var zoom_min = 0
|
||||
var zoom_max = 100
|
||||
var current_zoom = 0
|
||||
|
||||
func reset():
|
||||
basis = Basis()
|
||||
|
|
@ -23,6 +26,10 @@ func _input(event):
|
|||
if event is InputEventMouseMotion:
|
||||
mouse_x_velocity = event.relative.x
|
||||
mouse_y_velocity = event.relative.y
|
||||
elif event.is_action_pressed("zoom_out"):
|
||||
current_zoom += 5
|
||||
elif event.is_action_pressed("zoom_in"):
|
||||
current_zoom -= 5
|
||||
|
||||
func _process(delta):
|
||||
# rotate outer gimbal around y axis
|
||||
|
|
@ -56,3 +63,6 @@ func _process(delta):
|
|||
# reset gimbals
|
||||
if Input.is_action_pressed("cam_reset"):
|
||||
reset()
|
||||
|
||||
current_zoom = clamp(current_zoom,zoom_min,zoom_max)
|
||||
$InnerGimbal/Camera3D.position = Vector3($InnerGimbal/Camera3D.position.x,current_zoom,current_zoom)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue