-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The automatic determination for the FEZLVL "Size" parameter was bugging out, causing some triles and AOs to disappear. I think I fixed it... Also updated the links in the About pane, and started working on a FreeCam mode.
- Loading branch information
1 parent
76e078c
commit 843b583
Showing
12 changed files
with
258 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
[gd_scene load_steps=5 format=3 uid="uid://q6hiwea1m8ok"] | ||
[gd_scene load_steps=6 format=3 uid="uid://q6hiwea1m8ok"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://djsig0kkd1ved" path="res://Scenes/Cursor.tscn" id="1_qhvts"] | ||
[ext_resource type="PackedScene" uid="uid://cdwpy8hm6qseq" path="res://Scenes/UI.tscn" id="2_7lqbu"] | ||
[ext_resource type="Environment" uid="uid://ctohsq6knqpup" path="res://Materials/DefaultEnv.tres" id="3_tf75n"] | ||
[ext_resource type="PackedScene" uid="uid://dtgqsmedef7w7" path="res://Scenes/Stopper.tscn" id="4_1q8sn"] | ||
[ext_resource type="Script" path="res://addons/simple-free-look-camera-4-cf0bc21bfd15940b18ec42e3c6cae1ad385284c4/camera.gd" id="5_ad71m"] | ||
|
||
[node name="Main" type="Node"] | ||
|
||
[node name="UI" parent="." instance=ExtResource("2_7lqbu")] | ||
|
||
[node name="Cursor" parent="." instance=ExtResource("1_qhvts")] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1) | ||
|
||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] | ||
environment = ExtResource("3_tf75n") | ||
|
||
[node name="Stopper" parent="." instance=ExtResource("4_1q8sn")] | ||
visible = false | ||
|
||
[node name="DebugCam" type="Camera3D" parent="."] | ||
cull_mask = 1048574 | ||
script = ExtResource("5_ad71m") | ||
|
||
[connection signal="cursorPos" from="UI" to="Cursor" method="_on_ui_cursor_pos"] | ||
[connection signal="hasMoved" from="Cursor" to="UI" method="_on_cursor_has_moved"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
addons/simple-free-look-camera-4-cf0bc21bfd15940b18ec42e3c6cae1ad385284c4/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2020 Adam Viola | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
25 changes: 25 additions & 0 deletions
25
...ns/simple-free-look-camera-4-cf0bc21bfd15940b18ec42e3c6cae1ad385284c4/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simple Free-Look Camera | ||
A simple 3D 100-line free-look camera for Godot 4.0 that mimics the functionality of the editor's camera for in-game use. | ||
|
||
Ported from [Adamviola's Godot 3.2 version](https://github.com/adamviola/simple-free-look-camera). | ||
|
||
## Usage | ||
Use **W** and **S** to move forward and backward. | ||
|
||
Use **A** and **D** to move left and right. | ||
|
||
Use **Q** and **E** to move up and down. | ||
|
||
Roll the **scroll wheel** to increase and decrease movement speed. | ||
|
||
Press **shift** to move faster, and hold **alt** to move slower. | ||
|
||
Hold down the **right mouse button** to rotate the camera. | ||
There's a slider in the editor to control mouse sensitivity. | ||
|
||
## Installation | ||
Attach `camera.gd` to your Camera3D node. That's it! | ||
|
||
## License | ||
[MIT](https://opensource.org/licenses/MIT). | ||
|
109 changes: 109 additions & 0 deletions
109
addons/simple-free-look-camera-4-cf0bc21bfd15940b18ec42e3c6cae1ad385284c4/camera.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
class_name FreeLookCamera extends Camera3D | ||
|
||
# Modifier keys' speed multiplier | ||
const SHIFT_MULTIPLIER = 2.5 | ||
const ALT_MULTIPLIER = 1.0 / SHIFT_MULTIPLIER | ||
|
||
@export_range(0.0, 1.0) var sensitivity = 0.25 | ||
|
||
# Mouse state | ||
var _mouse_position = Vector2(0.0, 0.0) | ||
var _total_pitch = 0.0 | ||
|
||
# Movement state | ||
var _direction = Vector3(0.0, 0.0, 0.0) | ||
var _velocity = Vector3(0.0, 0.0, 0.0) | ||
var _acceleration = 30 | ||
var _deceleration = -10 | ||
var _vel_multiplier = 4 | ||
|
||
# Keyboard state | ||
var _w = false | ||
var _s = false | ||
var _a = false | ||
var _d = false | ||
var _q = false | ||
var _e = false | ||
var _shift = false | ||
var _alt = false | ||
|
||
func _input(event): | ||
# Receives mouse motion | ||
if event is InputEventMouseMotion: | ||
_mouse_position = event.relative | ||
|
||
# Receives mouse button input | ||
if event is InputEventMouseButton: | ||
match event.button_index: | ||
MOUSE_BUTTON_RIGHT: # Only allows rotation if right click down | ||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED if event.pressed else Input.MOUSE_MODE_VISIBLE) | ||
MOUSE_BUTTON_WHEEL_UP: # Increases max velocity | ||
_vel_multiplier = clamp(_vel_multiplier * 1.1, 0.2, 20) | ||
MOUSE_BUTTON_WHEEL_DOWN: # Decereases max velocity | ||
_vel_multiplier = clamp(_vel_multiplier / 1.1, 0.2, 20) | ||
|
||
# Receives key input | ||
if event is InputEventKey: | ||
match event.keycode: | ||
KEY_W: | ||
_w = event.pressed | ||
KEY_S: | ||
_s = event.pressed | ||
KEY_A: | ||
_a = event.pressed | ||
KEY_D: | ||
_d = event.pressed | ||
KEY_Q: | ||
_q = event.pressed | ||
KEY_E: | ||
_e = event.pressed | ||
|
||
# Updates mouselook and movement every frame | ||
func _process(delta): | ||
_update_mouselook() | ||
_update_movement(delta) | ||
|
||
# Updates camera movement | ||
func _update_movement(delta): | ||
# Computes desired direction from key states | ||
_direction = Vector3((_d as float) - (_a as float), | ||
(_e as float) - (_q as float), | ||
(_s as float) - (_w as float)) | ||
|
||
# Computes the change in velocity due to desired direction and "drag" | ||
# The "drag" is a constant acceleration on the camera to bring it's velocity to 0 | ||
var offset = _direction.normalized() * _acceleration * _vel_multiplier * delta \ | ||
+ _velocity.normalized() * _deceleration * _vel_multiplier * delta | ||
|
||
# Compute modifiers' speed multiplier | ||
var speed_multi = 1 | ||
if _shift: speed_multi *= SHIFT_MULTIPLIER | ||
if _alt: speed_multi *= ALT_MULTIPLIER | ||
|
||
# Checks if we should bother translating the camera | ||
if _direction == Vector3.ZERO and offset.length_squared() > _velocity.length_squared(): | ||
# Sets the velocity to 0 to prevent jittering due to imperfect deceleration | ||
_velocity = Vector3.ZERO | ||
else: | ||
# Clamps speed to stay within maximum value (_vel_multiplier) | ||
_velocity.x = clamp(_velocity.x + offset.x, -_vel_multiplier, _vel_multiplier) | ||
_velocity.y = clamp(_velocity.y + offset.y, -_vel_multiplier, _vel_multiplier) | ||
_velocity.z = clamp(_velocity.z + offset.z, -_vel_multiplier, _vel_multiplier) | ||
|
||
translate(_velocity * delta * speed_multi) | ||
|
||
# Updates mouse look | ||
func _update_mouselook(): | ||
# Only rotates mouse if the mouse is captured | ||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: | ||
_mouse_position *= sensitivity | ||
var yaw = _mouse_position.x | ||
var pitch = _mouse_position.y | ||
_mouse_position = Vector2(0, 0) | ||
|
||
# Prevents looking up/down too far | ||
pitch = clamp(pitch, -90 - _total_pitch, 90 - _total_pitch) | ||
_total_pitch += pitch | ||
|
||
rotate_y(deg_to_rad(-yaw)) | ||
rotate_object_local(Vector3(1,0,0), deg_to_rad(-pitch)) |
Oops, something went wrong.