world: added grass and sky #5
1 changed files with 11 additions and 4 deletions
|
|
@ -7,8 +7,10 @@ var locked_mouse_positon = Vector2(0,0)
|
||||||
var mouse_locked = false
|
var mouse_locked = false
|
||||||
var mouse_x_velocity = 0
|
var mouse_x_velocity = 0
|
||||||
var mouse_y_velocity = 0
|
var mouse_y_velocity = 0
|
||||||
|
|
||||||
var zoom_min = 4
|
var zoom_min = 4
|
||||||
var zoom_max = 100
|
var zoom_max = 80
|
||||||
|
var zoom_speed = 20
|
||||||
var current_zoom = 8
|
var current_zoom = 8
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
|
|
@ -27,9 +29,9 @@ func _input(event):
|
||||||
mouse_x_velocity = event.relative.x
|
mouse_x_velocity = event.relative.x
|
||||||
mouse_y_velocity = event.relative.y
|
mouse_y_velocity = event.relative.y
|
||||||
elif event.is_action_pressed("zoom_out"):
|
elif event.is_action_pressed("zoom_out"):
|
||||||
current_zoom += 5
|
current_zoom += 1
|
||||||
elif event.is_action_pressed("zoom_in"):
|
elif event.is_action_pressed("zoom_in"):
|
||||||
current_zoom -= 5
|
current_zoom -= 1
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# rotate outer gimbal around y axis
|
# rotate outer gimbal around y axis
|
||||||
|
|
@ -65,4 +67,9 @@ func _process(delta):
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
current_zoom = clamp(current_zoom, zoom_min, zoom_max)
|
current_zoom = clamp(current_zoom, zoom_min, zoom_max)
|
||||||
$InnerGimbal/Camera3D.position = Vector3($InnerGimbal/Camera3D.position.x, current_zoom, current_zoom)
|
|
||||||
|
var pos = Vector3($InnerGimbal/Camera3D.position)
|
||||||
|
pos.y = lerp(pos.y, float(current_zoom), zoom_speed*delta)
|
||||||
|
pos.z = lerp(pos.z, float(current_zoom), zoom_speed*delta)
|
||||||
|
|
|||||||
|
|
||||||
|
$InnerGimbal/Camera3D.position = pos
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
This is great work bro but these last three lines can be improved to something like this:
Since we instantiate
pto be a copy of the Camera3D's position on the first line, we don't need to assignp.xmanually. And the lines are shorter so they can fit in an editor without going over the edge 😁Also we call lerp with
p's properties instead of the long name ($InnerGimbal/...). If the path to the Camera3D changes we only need to change one reference where we definepinstead of replacing the whole lot.Also please put spaces on both sides of the asterisks 😁