Add camera to center function

Thanks to

Co-Authored-By: hakro <3624853+hakro@users.noreply.github.com>
pull/6/head
Kenney 2023-09-28 18:01:39 +07:00
parent 60c893fd25
commit 1a8ab357e4
3 changed files with 11 additions and 0 deletions

@ -19,6 +19,7 @@ This package includes a basic template for a 3D city builder in Godot 4.1.1.stab
| Key | Command |
| --- | --- |
| <kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> | Move camera |
| <kbd>F</kbd> | Camera to center |
| <kbd>Middle mouse button</kbd> | Hold to rotate camera |
| <kbd>Left mouse button</kbd> | Place building |
| <kbd>DEL</kbd> | Remove building |

@ -79,6 +79,11 @@ load={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194333,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
camera_center={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"echo":false,"script":null)
]
}
[rendering]

@ -34,6 +34,11 @@ func handle_input(_delta):
input = input.rotated(Vector3.UP, rotation.y).normalized()
camera_position += input / 4
# Back to center
if Input.is_action_pressed("camera_center"):
camera_position = Vector3()
func _input(event):