mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +01:00
Improve style in many demos (#1263)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -15,7 +16,7 @@ var camera_distance := 2.0
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera3D
|
||||
@onready var fps_label: Label = $FPSLabel
|
||||
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -41,22 +42,22 @@ func _ready() -> void:
|
||||
get_viewport().size_changed.connect(_on_viewport_size_changed)
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
|
||||
var tester_index := 0
|
||||
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance := 4.0
|
||||
var tester_index: int = 0
|
||||
var rot_x: float = -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y: float = TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance: float = 4.0
|
||||
|
||||
@onready var testers: Node3D = $Testers
|
||||
@onready var camera_holder: Node3D = $CameraHolder # Has a position and rotates on Y.
|
||||
@@ -29,22 +30,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -14,19 +15,20 @@ var zoom := 1.5
|
||||
@onready var rotation_x: Node3D = $CameraHolder/RotationX
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
|
||||
rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event.is_action_pressed(&"place_decal"):
|
||||
if input_event.is_action_pressed(&"place_decal"):
|
||||
var origin := camera.global_position
|
||||
var target := camera.project_position(get_viewport().get_mouse_position(), 100)
|
||||
|
||||
@@ -40,16 +42,16 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
decal.position = result["position"]
|
||||
decal.transform.basis = camera.global_transform.basis
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clampf(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clampf(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.002
|
||||
const MOVE_SPEED = 1.5
|
||||
|
||||
@@ -10,16 +11,16 @@ func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
transform.basis = Basis.from_euler(rot)
|
||||
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
|
||||
@@ -51,7 +51,7 @@ var gi_mode_texts: Array[String] = [
|
||||
var gi_mode := GIMode.NONE
|
||||
var reflection_probe_mode := ReflectionProbeMode.NONE
|
||||
var ssil_mode := SSILMode.NONE
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
# This is replaced further below if using Compatibility to point to a newly created DirectionalLight3D
|
||||
# (which does not affect sky rendering).
|
||||
@@ -93,8 +93,8 @@ Escape or F10: Toggle mouse capture"""
|
||||
set_ssil_mode(ssil_mode)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"cycle_gi_mode"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"cycle_gi_mode"):
|
||||
if is_compatibility:
|
||||
# Only LightmapGI is supported in Compatibility.
|
||||
# Note that the actual GI mode is the opposite of what's being set here, due to a bug
|
||||
@@ -103,10 +103,10 @@ func _input(event: InputEvent) -> void:
|
||||
else:
|
||||
set_gi_mode(wrapi(gi_mode + 1, 0, GIMode.MAX))
|
||||
|
||||
if event.is_action_pressed(&"cycle_reflection_probe_mode"):
|
||||
if input_event.is_action_pressed(&"cycle_reflection_probe_mode"):
|
||||
set_reflection_probe_mode(wrapi(reflection_probe_mode + 1, 0, ReflectionProbeMode.MAX))
|
||||
|
||||
if event.is_action_pressed(&"cycle_ssil_mode"):
|
||||
if input_event.is_action_pressed(&"cycle_ssil_mode"):
|
||||
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ extends Control
|
||||
@onready var fps_label := $FPSLabel
|
||||
@onready var resolution_label := $ResolutionLabel
|
||||
|
||||
var counter := 0.0
|
||||
var counter: float = 0.0
|
||||
|
||||
# When the screen changes size, we need to update the 3D
|
||||
# viewport quality setting. If we don't do this, the viewport will take
|
||||
@@ -20,7 +20,7 @@ var viewport_start_size := Vector2(
|
||||
ProjectSettings.get_setting(&"display/window/size/viewport_height")
|
||||
)
|
||||
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
|
||||
var tester_index := 0
|
||||
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance := 2.0
|
||||
var tester_index: int = 0
|
||||
var rot_x: float = -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y: float = TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance: float = 2.0
|
||||
|
||||
@onready var testers: Node3D = $Testers
|
||||
@onready var camera_holder: Node3D = $CameraHolder # Has a position and rotates on Y.
|
||||
@@ -21,25 +22,25 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
camera_distance = clampf(camera_distance, 1.5, 6.0)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
rot_x = clampf(rot_x, -1.57, 0.0)
|
||||
camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
|
||||
rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
|
||||
|
||||
@@ -54,12 +55,12 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func _on_previous_pressed() -> void:
|
||||
tester_index = max(0, tester_index - 1)
|
||||
tester_index = maxi(0, tester_index - 1)
|
||||
update_gui()
|
||||
|
||||
|
||||
func _on_next_pressed() -> void:
|
||||
tester_index = min(tester_index + 1, testers.get_child_count() - 1)
|
||||
tester_index = mini(tester_index + 1, testers.get_child_count() - 1)
|
||||
update_gui()
|
||||
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ func set_health(p_health: int) -> void:
|
||||
|
||||
# Construct a health bar with `|` symbols brought very close to each other using
|
||||
# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
|
||||
var bar_text := ""
|
||||
var bar_text_bg := ""
|
||||
var bar_text: String = ""
|
||||
var bar_text_bg: String = ""
|
||||
for i in roundi((health / 100.0) * BAR_WIDTH):
|
||||
bar_text += "|"
|
||||
for i in BAR_WIDTH:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -21,22 +22,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const INTERP_SPEED = 2
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.1
|
||||
@@ -26,6 +27,7 @@ var backgrounds: Array[Dictionary] = [
|
||||
@onready var rotation_x: Node3D = $CameraHolder/RotationX
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||
# Tweak scene brightness to better match Forward+/Mobile.
|
||||
@@ -38,23 +40,23 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 2, 8)
|
||||
camera.position.z = zoom
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_y = clamp(rot_y, -1.95, 1.95)
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Marker3D
|
||||
|
||||
@export var character_speed := 10.0
|
||||
@export var show_path := true
|
||||
@export var show_path: bool = true
|
||||
|
||||
var _nav_path_line: Line3D
|
||||
|
||||
@@ -33,7 +33,7 @@ func set_target_position(target_position: Vector3) -> void:
|
||||
# Get a full navigation path with the NavigationServer API.
|
||||
if show_path:
|
||||
var start_position := global_transform.origin
|
||||
var optimize := true
|
||||
var optimize: bool = true
|
||||
var navigation_map := get_world_3d().get_navigation_map()
|
||||
var path := NavigationServer3D.map_get_path(
|
||||
navigation_map,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const Character = preload("res://character.gd")
|
||||
|
||||
var _cam_rotation := 0.0
|
||||
@@ -7,10 +8,11 @@ var _cam_rotation := 0.0
|
||||
@onready var _camera := $CameraBase/Camera3D as Camera3D
|
||||
@onready var _robot := $RobotBase as Character
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseButton and input_event.button_index == MOUSE_BUTTON_LEFT and input_event.pressed:
|
||||
# Get closest point on navmesh for the current mouse cursor position.
|
||||
var mouse_cursor_position: Vector2 = event.position
|
||||
var mouse_cursor_position: Vector2 = input_event.position
|
||||
var camera_ray_length := 1000.0
|
||||
var camera_ray_start := _camera.project_ray_origin(mouse_cursor_position)
|
||||
var camera_ray_end := camera_ray_start + _camera.project_ray_normal(mouse_cursor_position) * camera_ray_length
|
||||
@@ -22,7 +24,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
)
|
||||
_robot.set_target_position(closest_point_on_navmesh)
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
if event.button_mask & (MOUSE_BUTTON_MASK_MIDDLE + MOUSE_BUTTON_MASK_RIGHT):
|
||||
_cam_rotation -= event.screen_relative.x * 0.005
|
||||
elif input_event is InputEventMouseMotion:
|
||||
if input_event.button_mask & (MOUSE_BUTTON_MASK_MIDDLE + MOUSE_BUTTON_MASK_RIGHT):
|
||||
_cam_rotation -= input_event.screen_relative.x * 0.005
|
||||
$CameraBase.set_rotation(Vector3.UP * _cam_rotation)
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.002
|
||||
const MOVE_SPEED = 1.5
|
||||
|
||||
var rot := Vector3()
|
||||
var velocity := Vector3()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
transform.basis = Basis.from_euler(rot)
|
||||
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
extends Node3D
|
||||
|
||||
var open := false
|
||||
var open: bool = false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_doors"):
|
||||
if open:
|
||||
# Close the door.
|
||||
# The occluder will be re-enabled when the animation ends
|
||||
# using `_on_animation_player_animation_finished()`.
|
||||
$AnimationPlayer.play_backwards(&"open")
|
||||
open = false
|
||||
else:
|
||||
# Open the door.
|
||||
$AnimationPlayer.play(&"open")
|
||||
open = true
|
||||
# Disable the occluder as soon as the door starts opening.
|
||||
# The occluder is not part of the pivot to prevent it from having its
|
||||
# position changed every frame, which causes the occlusion culling BVH
|
||||
# to be rebuilt each frame. This causes a CPU performance penalty.
|
||||
$OccluderInstance3D.visible = false
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if not input_event.is_action_pressed(&"toggle_doors"):
|
||||
return
|
||||
if open:
|
||||
# Close the door.
|
||||
# The occluder will be re-enabled when the animation ends
|
||||
# using `_on_animation_player_animation_finished()`.
|
||||
$AnimationPlayer.play_backwards(&"open")
|
||||
open = false
|
||||
else:
|
||||
# Open the door.
|
||||
$AnimationPlayer.play(&"open")
|
||||
open = true
|
||||
# Disable the occluder as soon as the door starts opening.
|
||||
# The occluder is not part of the pivot to prevent it from having its
|
||||
# position changed every frame, which causes the occlusion culling BVH
|
||||
# to be rebuilt each frame. This causes a CPU performance penalty.
|
||||
$OccluderInstance3D.visible = false
|
||||
|
||||
|
||||
func _on_animation_player_animation_finished(_anim_name: StringName) -> void:
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
extends Node3D
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_occlusion_culling"):
|
||||
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"toggle_occlusion_culling"):
|
||||
get_viewport().use_occlusion_culling = not get_viewport().use_occlusion_culling
|
||||
update_labels()
|
||||
if event.is_action_pressed(&"toggle_mesh_lod"):
|
||||
if input_event.is_action_pressed(&"toggle_mesh_lod"):
|
||||
get_viewport().mesh_lod_threshold = 1.0 if is_zero_approx(get_viewport().mesh_lod_threshold) else 0.0
|
||||
update_labels()
|
||||
if event.is_action_pressed(&"cycle_draw_mode"):
|
||||
if input_event.is_action_pressed(&"cycle_draw_mode"):
|
||||
get_viewport().debug_draw = wrapi(get_viewport().debug_draw + 1, 0, 5) as Viewport.DebugDraw
|
||||
update_labels()
|
||||
if event.is_action_pressed(&"toggle_vsync"):
|
||||
if input_event.is_action_pressed(&"toggle_vsync"):
|
||||
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
|
||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
|
||||
else:
|
||||
|
||||
@@ -20,22 +20,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@export var sun: DirectionalLight3D
|
||||
@export var lightbulb_1: OmniLight3D
|
||||
@export var lightbulb_2: OmniLight3D
|
||||
@export var world_environment: WorldEnvironment
|
||||
|
||||
|
||||
## Returns color from a given temperature in kelvins (6500K is nearly white).
|
||||
## Valid range is [1000; 15000].
|
||||
## As explained in the Filament documentation:
|
||||
|
||||
@@ -45,10 +45,10 @@ func _ready() -> void:
|
||||
cycle_camera_type()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
_yaw -= event.screen_relative.x * MOUSE_SENSITIVITY * 0.001
|
||||
_pitch += event.screen_relative.y * MOUSE_SENSITIVITY * 0.002
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseMotion:
|
||||
_yaw -= input_event.screen_relative.x * MOUSE_SENSITIVITY * 0.001
|
||||
_pitch += input_event.screen_relative.y * MOUSE_SENSITIVITY * 0.002
|
||||
_pitch = clamp(_pitch, -PI, PI)
|
||||
$Rig.rotation = Vector3(0, _yaw, 0)
|
||||
|
||||
|
||||
@@ -96,10 +96,10 @@ character_jump={
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
jolt_physics_3d/limits/temporary_memory_buffer_size=128
|
||||
jolt_physics_3d/limits/temporary_memory_buffer_size=256
|
||||
jolt_physics_3d/limits/max_bodies=262144
|
||||
jolt_physics_3d/limits/max_body_pairs=262144
|
||||
jolt_physics_3d/limits/max_contact_constraints=262144
|
||||
jolt_physics_3d/limits/max_contact_constraints=524288
|
||||
common/physics_interpolation=true
|
||||
|
||||
[rendering]
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
class_name Test
|
||||
extends Node
|
||||
|
||||
|
||||
signal wait_done()
|
||||
|
||||
@export var _enable_debug_collision := true
|
||||
@export var _enable_debug_collision: bool = true
|
||||
|
||||
var _timer: Timer
|
||||
var _timer_started := false
|
||||
var _timer_started: bool = false
|
||||
|
||||
var _wait_physics_ticks_counter := 0
|
||||
var _wait_physics_ticks_counter: int = 0
|
||||
|
||||
var _drawn_nodes: Array[Node3D] = []
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if not _enable_debug_collision:
|
||||
get_tree().debug_collisions_hint = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_TYPE_BOX = "Collision type/Box (1)"
|
||||
const OPTION_TYPE_SPHERE = "Collision type/Sphere (2)"
|
||||
const OPTION_TYPE_CAPSULE = "Collision type/Capsule (3)"
|
||||
@@ -17,10 +18,11 @@ const OFFSET_RANGE = 3.0
|
||||
|
||||
@export var offset := Vector3.ZERO
|
||||
|
||||
var _update_collision := false
|
||||
var _collision_test_index := 0
|
||||
var _update_collision: bool = false
|
||||
var _collision_test_index: int = 0
|
||||
var _collision_shapes: Array[Shape3D] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_collision_shapes()
|
||||
|
||||
@@ -47,17 +49,17 @@ func _ready() -> void:
|
||||
_update_collision = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_1:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and input_event.pressed:
|
||||
if input_event.keycode == KEY_1:
|
||||
_on_option_selected(OPTION_TYPE_BOX)
|
||||
elif event.keycode == KEY_2:
|
||||
elif input_event.keycode == KEY_2:
|
||||
_on_option_selected(OPTION_TYPE_SPHERE)
|
||||
elif event.keycode == KEY_3:
|
||||
elif input_event.keycode == KEY_3:
|
||||
_on_option_selected(OPTION_TYPE_CAPSULE)
|
||||
elif event.keycode == KEY_4:
|
||||
elif input_event.keycode == KEY_4:
|
||||
_on_option_selected(OPTION_TYPE_CYLINDER)
|
||||
elif event.keycode == KEY_5:
|
||||
elif input_event.keycode == KEY_5:
|
||||
_on_option_selected(OPTION_TYPE_CONVEX_POLYGON)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_JOINT_TYPE = "Joint Type/%s Joint (%d)"
|
||||
|
||||
const OPTION_TEST_CASE_BODIES_COLLIDE = "Test case/Attached bodies collide"
|
||||
@@ -10,27 +11,28 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
|
||||
|
||||
const BOX_SIZE = Vector3(1.0, 1.0, 1.0)
|
||||
|
||||
var _update_joint := false
|
||||
var _update_joint: bool = false
|
||||
var _selected_joint: Joint3D
|
||||
|
||||
var _bodies_collide := false
|
||||
var _world_attachement := false
|
||||
var _dynamic_attachement := false
|
||||
var _destroy_body := false
|
||||
var _change_positions := false
|
||||
var _bodies_collide: bool = false
|
||||
var _world_attachement: bool = false
|
||||
var _dynamic_attachement: bool = false
|
||||
var _destroy_body: bool = false
|
||||
var _change_positions: bool = false
|
||||
|
||||
var _joint_types: Dictionary[String, Joint3D] = {}
|
||||
|
||||
var _joint_types := {}
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
|
||||
var joints: Node3D = $Joints
|
||||
for joint_index in joints.get_child_count():
|
||||
var joint_node := joints.get_child(joint_index)
|
||||
var joint_node: Joint3D = joints.get_child(joint_index)
|
||||
joint_node.visible = false
|
||||
var joint_name := String(joint_node.name)
|
||||
var joint_short := joint_name.substr(0, joint_name.length() - 5)
|
||||
var option_name := OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
var joint_short: String = joint_name.substr(0, joint_name.length() - 5)
|
||||
var option_name: String = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
options.add_menu_item(option_name)
|
||||
_joint_types[option_name] = joint_node
|
||||
|
||||
@@ -54,9 +56,9 @@ func _process(_delta: float) -> void:
|
||||
$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
var joint_index: int = event.keycode - KEY_1
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and input_event.pressed:
|
||||
var joint_index: int = input_event.keycode - KEY_1
|
||||
if joint_index >= 0 and joint_index < _joint_types.size():
|
||||
_selected_joint = _joint_types.values()[joint_index]
|
||||
_update_joint = true
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_BODY_TYPE = "Body Type/%s (%d)"
|
||||
|
||||
const OPTION_SLOPE = "Physics options/Stop on slope (Character only)"
|
||||
@@ -14,21 +15,22 @@ const SHAPE_CYLINDER = "Collision shapes/Cylinder"
|
||||
const SHAPE_SPHERE = "Collision shapes/Sphere"
|
||||
const SHAPE_CONVEX = "Collision shapes/Convex"
|
||||
|
||||
var _slope := false
|
||||
var _snap := false
|
||||
var _friction := false
|
||||
var _rough := false
|
||||
var _animation_physics := false
|
||||
var _slope: bool = false
|
||||
var _snap: bool = false
|
||||
var _friction: bool = false
|
||||
var _rough: bool = false
|
||||
var _animation_physics: bool = false
|
||||
|
||||
var _body_scene := {}
|
||||
var _key_list := []
|
||||
var _current_body_index := 0
|
||||
var _current_body_key := ""
|
||||
var _current_body_key: String = ""
|
||||
var _current_body: PhysicsBody3D = null
|
||||
var _body_type := ["CharacterBody3D", "RigidBody"]
|
||||
|
||||
var _shapes := {}
|
||||
var _current_shape := ""
|
||||
var _current_shape: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
@@ -66,9 +68,9 @@ func _ready() -> void:
|
||||
spawn_body_index(_current_body_index)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and not event.pressed:
|
||||
var _index: int = event.keycode - KEY_1
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
var _index: int = input_event.keycode - KEY_1
|
||||
if _index >= 0 and _index < _key_list.size():
|
||||
spawn_body_index(_index)
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
extends Test
|
||||
|
||||
@export_range(1, 100) var height := 10
|
||||
@export_range(1, 100) var width_max := 100
|
||||
@export_range(1, 100) var depth_max := 1
|
||||
|
||||
@export_range(1, 100) var height: int = 10
|
||||
@export_range(1, 100) var width_max: int = 100
|
||||
@export_range(1, 100) var depth_max: int = 1
|
||||
@export var box_size := Vector3(1.0, 1.0, 1.0)
|
||||
@export var box_spacing := Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_pyramid()
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
|
||||
|
||||
var _hit_from_inside := false
|
||||
var _do_raycasts := false
|
||||
var _hit_from_inside: bool = false
|
||||
var _do_raycasts: bool = false
|
||||
|
||||
@onready var _raycast_visuals := ImmediateMesh.new()
|
||||
@onready var _material := StandardMaterial3D.new()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_BIG = "Floor options/Big"
|
||||
const OPTION_SMALL = "Floor options/Small"
|
||||
|
||||
@@ -8,13 +9,14 @@ const SHAPE_CONVEX = "Collision shapes/Convex"
|
||||
const SHAPE_BOX = "Collision shapes/Box"
|
||||
|
||||
var _dynamic_shapes_scene: PackedScene
|
||||
var _floor_shapes := {}
|
||||
var _floor_size := "Small"
|
||||
var _floor_shapes: Dictionary[String, PackedScene] = {}
|
||||
var _floor_size: String = "Small"
|
||||
|
||||
var _current_floor_name := SHAPE_CONCAVE
|
||||
var _current_bodies: Node3D
|
||||
var _current_floor: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
_dynamic_shapes_scene = get_packed_scene($DynamicShapes/Bodies)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
extends Test
|
||||
|
||||
@export_range(1, 100) var height := 10
|
||||
@export_range(1, 100) var width := 1
|
||||
@export_range(1, 100) var depth := 1
|
||||
|
||||
@export_range(1, 100) var height: int = 10
|
||||
@export_range(1, 100) var width: int = 1
|
||||
@export_range(1, 100) var depth: int = 1
|
||||
@export var box_size := Vector3(1.0, 1.0, 1.0)
|
||||
@export var box_spacing := Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_stack()
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const BOX_SIZE = Vector3(0.8, 0.8, 0.8)
|
||||
const BOX_SPACE = Vector3(1.0, 1.0, 1.0)
|
||||
|
||||
@export_range(1, 1000) var row_size := 20
|
||||
@export_range(1, 1000) var column_size := 20
|
||||
@export_range(1, 1000) var depth_size := 20
|
||||
@export_range(1, 1000) var row_size: int = 20
|
||||
@export_range(1, 1000) var column_size: int = 20
|
||||
@export_range(1, 1000) var depth_size: int = 20
|
||||
|
||||
var _objects: Array[Node3D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time_usec: int = 0
|
||||
var _log_physics_time_usec_start: int = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
await start_timer(1.0).timeout
|
||||
@@ -75,16 +77,16 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
if _log_physics:
|
||||
var time := Time.get_ticks_usec()
|
||||
var time_delta := time - _log_physics_time
|
||||
var time_total := time - _log_physics_time_start
|
||||
_log_physics_time = time
|
||||
var time_delta := time - _log_physics_time_usec
|
||||
var time_total := time - _log_physics_time_usec_start
|
||||
_log_physics_time_usec = time
|
||||
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
|
||||
|
||||
|
||||
func _log_physics_start() -> void:
|
||||
_log_physics = true
|
||||
_log_physics_time_start = Time.get_ticks_usec()
|
||||
_log_physics_time = _log_physics_time_start
|
||||
_log_physics_time_usec_start = Time.get_ticks_usec()
|
||||
_log_physics_time_usec = _log_physics_time_usec_start
|
||||
|
||||
|
||||
func _log_physics_stop() -> void:
|
||||
|
||||
@@ -8,14 +8,14 @@ const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
|
||||
const OPTION_TYPE_CONVEX = "Shape type/Convex"
|
||||
|
||||
@export var spawns: Array[NodePath] = []
|
||||
@export var spawn_count := 100
|
||||
@export var spawn_count: int = 100
|
||||
@export var spawn_randomize := Vector3.ZERO
|
||||
|
||||
var _object_templates: Array[Node3D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time_usec: int = 0
|
||||
var _log_physics_time_usec_start: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
await start_timer(0.5).timeout
|
||||
@@ -48,16 +48,16 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
if _log_physics:
|
||||
var time := Time.get_ticks_usec()
|
||||
var time_delta := time - _log_physics_time
|
||||
var time_total := time - _log_physics_time_start
|
||||
_log_physics_time = time
|
||||
var time_delta := time - _log_physics_time_usec
|
||||
var time_total := time - _log_physics_time_usec_start
|
||||
_log_physics_time_usec = time
|
||||
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
|
||||
|
||||
|
||||
func _log_physics_start() -> void:
|
||||
_log_physics = true
|
||||
_log_physics_time_start = Time.get_ticks_usec()
|
||||
_log_physics_time = _log_physics_time_start
|
||||
_log_physics_time_usec_start = Time.get_ticks_usec()
|
||||
_log_physics_time_usec = _log_physics_time_usec_start
|
||||
|
||||
|
||||
func _log_physics_stop() -> void:
|
||||
|
||||
@@ -2,8 +2,8 @@ extends OptionMenu
|
||||
|
||||
|
||||
class TestData:
|
||||
var id := ""
|
||||
var scene_path := ""
|
||||
var id: String = ""
|
||||
var scene_path: String = ""
|
||||
|
||||
|
||||
var _test_list: Array[TestData] = []
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const ROTATION_COEFF = 0.02
|
||||
|
||||
var _rotation_enabled := false
|
||||
var _rotation_enabled: bool = false
|
||||
var _rotation_pivot: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_pivot.call_deferred()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = event.pressed
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = input_event.pressed
|
||||
|
||||
return
|
||||
|
||||
if not _rotation_enabled:
|
||||
return
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
var rotation_delta: float = event.screen_relative.x
|
||||
if input_event is InputEventMouseMotion:
|
||||
var rotation_delta: float = input_event.screen_relative.x
|
||||
_rotation_pivot.rotate(Vector3.UP, -rotation_delta * ROTATION_COEFF)
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var _stop_on_slopes := false
|
||||
@export var use_snap := false
|
||||
|
||||
var _gravity := 20.0
|
||||
@export var _stop_on_slopes: bool = false
|
||||
@export var use_snap: bool = false
|
||||
|
||||
var _gravity: float = 20.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_on_floor():
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Control
|
||||
|
||||
|
||||
const MAX_ENTRIES = 100
|
||||
|
||||
var _entry_template: Label
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@export var world_offset := Vector3.ZERO
|
||||
|
||||
var _pos_offset: Vector2
|
||||
var _attachment: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_pos_offset = position
|
||||
_attachment = get_parent()
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var engine_name := ""
|
||||
var engine_name: String = ""
|
||||
match System.get_physics_engine():
|
||||
System.PhysicsEngine.GODOT_PHYSICS:
|
||||
engine_name = "GodotPhysics 3D"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
visible = get_tree().paused
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends Label
|
||||
|
||||
var test_name := "":
|
||||
|
||||
var test_name: String = "":
|
||||
set(value):
|
||||
if (test_name != value):
|
||||
return
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
set_text("Godot Version: %s" % Engine.get_version_info().string)
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
class_name OptionMenu
|
||||
extends MenuButton
|
||||
|
||||
|
||||
signal option_selected(item_path: String)
|
||||
signal option_changed(item_path: String, checked: bool)
|
||||
|
||||
|
||||
func add_menu_item(item_path: String, checkbox: bool = false, checked: bool = false) -> void:
|
||||
var path_elements := item_path.split("/", false)
|
||||
var path_element_count := path_elements.size()
|
||||
assert(path_element_count > 0)
|
||||
|
||||
var path := ""
|
||||
var path: String = ""
|
||||
var popup := get_popup()
|
||||
for element_index in path_element_count - 1:
|
||||
var popup_label := path_elements[element_index]
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var _dir := 1.0
|
||||
var _distance := 10.0
|
||||
var _walk_spd := 100.0
|
||||
var _acceleration := 22.0
|
||||
var _is_on_floor := false
|
||||
|
||||
var _dir: float = 1.0 # -1.0 or 1.0
|
||||
var _distance: float = 10.0
|
||||
var _walk_spd: float = 100.0
|
||||
var _acceleration: float = 22.0
|
||||
var _is_on_floor: bool = false
|
||||
|
||||
@onready var _forward := -transform.basis.z
|
||||
@onready var _collision_shape := $CollisionShape
|
||||
@onready var _material: StandardMaterial3D = $CollisionShape/MeshInstance3D.get_active_material(0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not _material:
|
||||
_material = StandardMaterial3D.new()
|
||||
@@ -24,20 +26,20 @@ func _process(_delta: float) -> void:
|
||||
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
var delta := state.step
|
||||
var velocity := (_forward * _dir * _walk_spd * delta) + (state.linear_velocity * Vector3.UP)
|
||||
var delta: float = state.step
|
||||
var velocity := (_forward * _dir * _walk_spd * delta) + (state.linear_velocity * Vector3.UP)
|
||||
state.linear_velocity = state.linear_velocity.move_toward(velocity, _acceleration * delta)
|
||||
|
||||
if state.transform.origin.z < -_distance:
|
||||
_dir = -1
|
||||
_dir = -1.0
|
||||
if state.transform.origin.z > _distance:
|
||||
_dir = 1
|
||||
_dir = 1.0
|
||||
|
||||
ground_check()
|
||||
|
||||
|
||||
func ground_check() -> void:
|
||||
var space_state := get_world_3d().direct_space_state
|
||||
var space_state: PhysicsDirectSpaceState3D = get_world_3d().direct_space_state
|
||||
var shape := PhysicsShapeQueryParameters3D.new()
|
||||
shape.transform = _collision_shape.global_transform
|
||||
shape.shape_rid = _collision_shape.shape.get_rid()
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
extends RigidBody3D
|
||||
|
||||
const MOUSE_DELTA_COEFFICIENT = 0.01
|
||||
const CAMERA_DISTANCE_COEFFICIENT = 0.2
|
||||
|
||||
var _picked := false
|
||||
const MOUSE_DELTA_COEFFICIENT: float = 0.01
|
||||
const CAMERA_DISTANCE_COEFFICIENT: float = 0.2
|
||||
|
||||
var _picked: bool = false
|
||||
var _last_mouse_pos := Vector2.ZERO
|
||||
var _mouse_pos := Vector2.ZERO
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
input_ray_pickable = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if not event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
func _input(any_input_event: InputEvent) -> void:
|
||||
if any_input_event is InputEventMouseButton:
|
||||
if not any_input_event.pressed and any_input_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
_picked = false
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
_mouse_pos = event.position
|
||||
if any_input_event is InputEventMouseMotion:
|
||||
_mouse_pos = any_input_event.position
|
||||
|
||||
|
||||
func _input_event(_camera: Camera3D, event: InputEvent, _position: Vector3, _normal: Vector3, _shape_idx: int) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
func _input_event(_camera: Camera3D, any_input_event: InputEvent, _position: Vector3, _normal: Vector3, _shape_idx: int) -> void:
|
||||
if any_input_event is InputEventMouseButton:
|
||||
if any_input_event.pressed and any_input_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
_picked = true
|
||||
_mouse_pos = event.position
|
||||
_mouse_pos = any_input_event.position
|
||||
_last_mouse_pos = _mouse_pos
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends ScrollContainer
|
||||
|
||||
@export var auto_scroll := false
|
||||
|
||||
@export var auto_scroll: bool = false
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if auto_scroll:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
enum PhysicsEngine {
|
||||
GODOT_PHYSICS,
|
||||
JOLT_PHYSICS,
|
||||
@@ -8,6 +9,7 @@ enum PhysicsEngine {
|
||||
|
||||
var _engine := PhysicsEngine.OTHER
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
enum LogType {
|
||||
LOG,
|
||||
ERROR,
|
||||
@@ -7,6 +8,7 @@ enum LogType {
|
||||
|
||||
signal entry_logged(message: String, type: LogType)
|
||||
|
||||
|
||||
func print_log(message: String) -> void:
|
||||
print(message)
|
||||
entry_logged.emit(message, LogType.LOG)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Area3D
|
||||
|
||||
var taken := false
|
||||
|
||||
var taken: bool = false
|
||||
|
||||
|
||||
func _on_coin_body_enter(body: Node) -> void:
|
||||
if not taken and body is Player:
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends RigidBody3D
|
||||
|
||||
const ACCEL = 5.0
|
||||
const DEACCEL = 20.0
|
||||
const MAX_SPEED = 2.0
|
||||
const ROT_SPEED = 1.0
|
||||
|
||||
var prev_advance := false
|
||||
var dying := false
|
||||
var rot_dir := 4
|
||||
const ACCEL: float = 5.0
|
||||
const DEACCEL: float = 20.0
|
||||
const MAX_SPEED: float = 2.0
|
||||
const ROT_SPEED: float = 1.0
|
||||
|
||||
var prev_advance: bool = false
|
||||
var dying: bool = false
|
||||
var rot_dir: float = 4.0
|
||||
|
||||
@onready var gravity := Vector3(
|
||||
ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||
@@ -17,6 +18,7 @@ var rot_dir := 4
|
||||
@onready var _ray_floor := $Enemy/Skeleton/RayFloor as RayCast3D
|
||||
@onready var _ray_wall := $Enemy/Skeleton/RayWall as RayCast3D
|
||||
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
var delta := state.get_step()
|
||||
var lin_velocity := state.get_linear_velocity()
|
||||
@@ -51,10 +53,10 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
$SoundHit.play()
|
||||
return
|
||||
|
||||
var advance := _ray_floor.is_colliding() and not _ray_wall.is_colliding()
|
||||
var advance: bool = _ray_floor.is_colliding() and not _ray_wall.is_colliding()
|
||||
|
||||
var dir := ($Enemy/Skeleton as Node3D).get_transform().basis[2].normalized()
|
||||
var deaccel_dir := dir
|
||||
var dir: Vector3 = ($Enemy/Skeleton as Node3D).get_transform().basis.z.normalized()
|
||||
var deaccel_dir: Vector3 = dir
|
||||
|
||||
if advance:
|
||||
if dir.dot(lin_velocity) < MAX_SPEED:
|
||||
@@ -67,7 +69,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
dir = Basis(up, rot_dir * ROT_SPEED * (delta)) * dir
|
||||
$Enemy/Skeleton.set_transform(Transform3D().looking_at(-dir, up))
|
||||
|
||||
var dspeed := deaccel_dir.dot(lin_velocity)
|
||||
var dspeed: float = deaccel_dir.dot(lin_velocity)
|
||||
dspeed -= DEACCEL * delta
|
||||
if dspeed < 0:
|
||||
dspeed = 0
|
||||
|
||||
@@ -3,4 +3,4 @@ extends RigidBody3D
|
||||
|
||||
## If `true`, the bullet can hit enemies. This is set to `false` when the bullet
|
||||
## hits an enemy so it can't hit an enemy multiple times while the bullet is fading out.
|
||||
var enabled := true
|
||||
var enabled: bool = true
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MAX_HEIGHT = 2.0
|
||||
const MIN_HEIGHT = 0.0
|
||||
|
||||
var collision_exception: Array[RID] = []
|
||||
|
||||
@export var min_distance := 0.5
|
||||
@export var max_distance := 3.5
|
||||
@export var angle_v_adjust := 0.0
|
||||
@export var autoturn_ray_aperture := 25.0
|
||||
@export var autoturn_speed := 50.0
|
||||
@export var min_distance: float = 0.5
|
||||
@export var max_distance: float = 3.5
|
||||
@export var angle_v_adjust: float = 0.0
|
||||
@export var autoturn_ray_aperture: float = 25.0
|
||||
@export var autoturn_speed: float = 50.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Find collision exceptions for ray.
|
||||
|
||||
@@ -6,26 +6,26 @@ enum _Anim {
|
||||
AIR,
|
||||
}
|
||||
|
||||
const SHOOT_TIME = 1.5
|
||||
const SHOOT_SCALE = 2.0
|
||||
const CHAR_SCALE = Vector3(0.3, 0.3, 0.3)
|
||||
const MAX_SPEED = 6.0
|
||||
const TURN_SPEED = 40.0
|
||||
const JUMP_VELOCITY = 12.5
|
||||
const BULLET_SPEED = 20.0
|
||||
const AIR_IDLE_DEACCEL = false
|
||||
const ACCEL = 14.0
|
||||
const DEACCEL = 14.0
|
||||
const AIR_ACCEL_FACTOR = 0.5
|
||||
const SHARP_TURN_THRESHOLD = deg_to_rad(140.0)
|
||||
const SHOOT_TIME: float = 1.5
|
||||
const SHOOT_SCALE: float = 2.0
|
||||
const CHAR_SCALE := Vector3(0.3, 0.3, 0.3)
|
||||
const MAX_SPEED: float = 6.0
|
||||
const TURN_SPEED: float = 40.0
|
||||
const JUMP_VELOCITY: float = 12.5
|
||||
const BULLET_SPEED: float = 20.0
|
||||
const AIR_IDLE_DEACCEL: bool = false
|
||||
const ACCEL: float = 14.0
|
||||
const DEACCEL: float = 14.0
|
||||
const AIR_ACCEL_FACTOR: float = 0.5
|
||||
const SHARP_TURN_THRESHOLD: float = deg_to_rad(140.0)
|
||||
|
||||
var movement_dir := Vector3()
|
||||
var jumping := false
|
||||
var prev_shoot := false
|
||||
var shoot_blend := 0.0
|
||||
var jumping: bool = false
|
||||
var prev_shoot: bool = false
|
||||
var shoot_blend: float = 0.0
|
||||
|
||||
# Number of coins collected.
|
||||
var coins := 0
|
||||
var coins: int = 0
|
||||
|
||||
@onready var initial_position := position
|
||||
@onready var gravity: Vector3 = ProjectSettings.get_setting("physics/3d/default_gravity") * \
|
||||
|
||||
@@ -154,6 +154,7 @@ common/physics_interpolation=true
|
||||
|
||||
renderer/rendering_method="mobile"
|
||||
textures/vram_compression/import_s3tc_bptc=true
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
lights_and_shadows/directional_shadow/size=8192
|
||||
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=3
|
||||
textures/default_filters/anisotropic_filtering_level=4
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends CanvasLayer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
hide()
|
||||
if DisplayServer.is_touchscreen_available():
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class_name VirtualJoystick
|
||||
|
||||
extends Control
|
||||
|
||||
## A simple virtual joystick for touchscreens, with useful options.
|
||||
@@ -11,10 +10,10 @@ extends Control
|
||||
@export var pressed_color := Color.GRAY
|
||||
|
||||
## If the input is inside this range, the output is zero.
|
||||
@export_range(0, 200, 1) var deadzone_size : float = 10
|
||||
@export_range(0, 200, 1) var deadzone_size: float = 10.0
|
||||
|
||||
## The max distance the tip can reach.
|
||||
@export_range(0, 500, 1) var clampzone_size : float = 75
|
||||
@export_range(0, 500, 1) var clampzone_size: float = 75.0
|
||||
|
||||
enum Joystick_mode {
|
||||
FIXED, ## The joystick doesn't move.
|
||||
@@ -35,30 +34,30 @@ enum Visibility_mode {
|
||||
@export var visibility_mode := Visibility_mode.ALWAYS
|
||||
|
||||
## If true, the joystick uses Input Actions. (Project -> Project Settings -> Input Map)
|
||||
@export var use_input_actions := true
|
||||
@export var use_input_actions: bool = true
|
||||
|
||||
@export var action_left := "move_left"
|
||||
@export var action_right := "move_right"
|
||||
@export var action_up := "move_forward"
|
||||
@export var action_down := "move_back"
|
||||
@export var action_left: String = "move_left"
|
||||
@export var action_right: String = "move_right"
|
||||
@export var action_up: String = "move_forward"
|
||||
@export var action_down: String = "move_back"
|
||||
|
||||
# PUBLIC VARIABLES
|
||||
|
||||
## If the joystick is receiving inputs.
|
||||
var is_pressed := false
|
||||
var is_pressed: bool = false
|
||||
|
||||
# The joystick output.
|
||||
var output := Vector2.ZERO
|
||||
|
||||
# PRIVATE VARIABLES
|
||||
|
||||
var _touch_index : int = -1
|
||||
var _touch_index: int = -1
|
||||
|
||||
@onready var _base := $Base
|
||||
@onready var _tip := $Base/Tip
|
||||
@onready var _base: TextureRect = $Base
|
||||
@onready var _tip: TextureRect = $Base/Tip
|
||||
|
||||
@onready var _base_default_position : Vector2 = _base.position
|
||||
@onready var _tip_default_position : Vector2 = _tip.position
|
||||
@onready var _base_default_position: Vector2 = _base.position
|
||||
@onready var _tip_default_position: Vector2 = _tip.position
|
||||
|
||||
@onready var _default_color : Color = _tip.modulate
|
||||
|
||||
@@ -72,27 +71,28 @@ func _ready() -> void:
|
||||
hide()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventScreenTouch:
|
||||
if event.pressed:
|
||||
if _is_point_inside_joystick_area(event.position) and _touch_index == -1:
|
||||
if joystick_mode == Joystick_mode.DYNAMIC or joystick_mode == Joystick_mode.FOLLOWING or (joystick_mode == Joystick_mode.FIXED and _is_point_inside_base(event.position)):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventScreenTouch:
|
||||
if input_event.pressed:
|
||||
if _is_point_inside_joystick_area(input_event.position) and _touch_index == -1:
|
||||
if joystick_mode == Joystick_mode.DYNAMIC or joystick_mode == Joystick_mode.FOLLOWING or (
|
||||
joystick_mode == Joystick_mode.FIXED and _is_point_inside_base(input_event.position)):
|
||||
if joystick_mode == Joystick_mode.DYNAMIC or joystick_mode == Joystick_mode.FOLLOWING:
|
||||
_move_base(event.position)
|
||||
_move_base(input_event.position)
|
||||
if visibility_mode == Visibility_mode.WHEN_TOUCHED:
|
||||
show()
|
||||
_touch_index = event.index
|
||||
_touch_index = input_event.index
|
||||
_tip.modulate = pressed_color
|
||||
_update_joystick(event.position)
|
||||
_update_joystick(input_event.position)
|
||||
get_viewport().set_input_as_handled()
|
||||
elif event.index == _touch_index:
|
||||
elif input_event.index == _touch_index:
|
||||
_reset()
|
||||
if visibility_mode == Visibility_mode.WHEN_TOUCHED:
|
||||
hide()
|
||||
get_viewport().set_input_as_handled()
|
||||
elif event is InputEventScreenDrag:
|
||||
if event.index == _touch_index:
|
||||
_update_joystick(event.position)
|
||||
elif input_event is InputEventScreenDrag:
|
||||
if input_event.index == _touch_index:
|
||||
_update_joystick(input_event.position)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
@@ -111,20 +111,20 @@ func _is_point_inside_joystick_area(point: Vector2) -> bool:
|
||||
|
||||
|
||||
func _get_base_radius() -> Vector2:
|
||||
return _base.size * _base.get_global_transform_with_canvas().get_scale() / 2
|
||||
return _base.size * _base.get_global_transform_with_canvas().get_scale() / 2.0
|
||||
|
||||
|
||||
func _is_point_inside_base(point: Vector2) -> bool:
|
||||
var base_radius: = _get_base_radius()
|
||||
var center : Vector2 = _base.global_position + base_radius
|
||||
var vector : Vector2 = point - center
|
||||
var base_radius: Vector2 = _get_base_radius()
|
||||
var center: Vector2 = _base.global_position + base_radius
|
||||
var vector: Vector2 = point - center
|
||||
return vector.length_squared() <= base_radius.x * base_radius.x
|
||||
|
||||
|
||||
func _update_joystick(touch_position: Vector2) -> void:
|
||||
var base_radius: = _get_base_radius()
|
||||
var center : Vector2 = _base.global_position + base_radius
|
||||
var vector : Vector2 = touch_position - center
|
||||
var base_radius: Vector2 = _get_base_radius()
|
||||
var center: Vector2 = _base.global_position + base_radius
|
||||
var vector: Vector2 = touch_position - center
|
||||
vector = vector.limit_length(clampzone_size)
|
||||
|
||||
if joystick_mode == Joystick_mode.FOLLOWING and touch_position.distance_to(center) > clampzone_size:
|
||||
@@ -141,23 +141,23 @@ func _update_joystick(touch_position: Vector2) -> void:
|
||||
|
||||
if use_input_actions:
|
||||
# Release actions.
|
||||
if output.x >= 0 and Input.is_action_pressed(action_left):
|
||||
if output.x >= 0.0 and Input.is_action_pressed(action_left):
|
||||
Input.action_release(action_left)
|
||||
if output.x <= 0 and Input.is_action_pressed(action_right):
|
||||
if output.x <= 0.0 and Input.is_action_pressed(action_right):
|
||||
Input.action_release(action_right)
|
||||
if output.y >= 0 and Input.is_action_pressed(action_up):
|
||||
if output.y >= 0.0 and Input.is_action_pressed(action_up):
|
||||
Input.action_release(action_up)
|
||||
if output.y <= 0 and Input.is_action_pressed(action_down):
|
||||
if output.y <= 0.0 and Input.is_action_pressed(action_down):
|
||||
Input.action_release(action_down)
|
||||
|
||||
# Press actions.
|
||||
if output.x < 0:
|
||||
if output.x < 0.0:
|
||||
Input.action_press(action_left, -output.x)
|
||||
if output.x > 0:
|
||||
if output.x > 0.0:
|
||||
Input.action_press(action_right, output.x)
|
||||
if output.y < 0:
|
||||
if output.y < 0.0:
|
||||
Input.action_press(action_up, -output.y)
|
||||
if output.y > 0:
|
||||
if output.y > 0.0:
|
||||
Input.action_press(action_down, output.y)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# This acts as a staging scene shown until the main scene is fully loaded.
|
||||
extends Control
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
for i in 2:
|
||||
# Wait 2 frames before starting to change to the main scene,
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
# which would make it much larger.
|
||||
extends MeshInstance3D
|
||||
|
||||
|
||||
const TEXTURE_SIZE = Vector2i(512, 512)
|
||||
const GRID_SIZE = 32
|
||||
const GRID_THICKNESS = 4
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var image := Image.create(TEXTURE_SIZE.x, TEXTURE_SIZE.y, false, Image.FORMAT_RGB8)
|
||||
# Use 1-dimensional loop as it's faster than a nested loop.
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
|
||||
var tester_index := 0
|
||||
var rot_x := deg_to_rad(-22.5) # This must be kept in sync with RotationX.
|
||||
var rot_y := deg_to_rad(90) # This must be kept in sync with CameraHolder.
|
||||
var zoom := 2.5
|
||||
var is_compatibility := false
|
||||
var tester_index: int = 0
|
||||
var rot_x: float = deg_to_rad(-22.5) # This must be kept in sync with RotationX.
|
||||
var rot_y: float = deg_to_rad(90) # This must be kept in sync with CameraHolder.
|
||||
var zoom: float = 2.5
|
||||
var is_compatibility: bool = false
|
||||
|
||||
@onready var testers: Node3D = $Testers
|
||||
@onready var camera_holder: Node3D = $CameraHolder # Has a position and rotates on Y.
|
||||
@onready var rotation_x: Node3D = $CameraHolder/RotationX
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||
# Use PCF13 shadow filtering to improve quality (Medium maps to PCF5 instead).
|
||||
@@ -32,22 +34,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clampf(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clampf(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.01
|
||||
const INITIAL_VELOCITY_STRENGTH = 0.5
|
||||
|
||||
@@ -13,11 +14,11 @@ const DIRECTIONAL_SHADOW_MAX_DISTANCE_MARGIN = 9.0
|
||||
@onready var directional_light: DirectionalLight3D = $DirectionalLight3D
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"reset_simulation"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"reset_simulation"):
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
if event.is_action_pressed(&"place_ragdoll"):
|
||||
if input_event.is_action_pressed(&"place_ragdoll"):
|
||||
var origin := camera.global_position
|
||||
var target := camera.project_position(get_viewport().get_mouse_position(), 100)
|
||||
|
||||
@@ -33,27 +34,27 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
ragdoll.initial_velocity = Vector3.FORWARD.rotated(Vector3.UP, randf_range(0, TAU)) * INITIAL_VELOCITY_STRENGTH
|
||||
add_child(ragdoll)
|
||||
|
||||
if event.is_action_pressed(&"slow_motion"):
|
||||
if input_event.is_action_pressed(&"slow_motion"):
|
||||
Engine.time_scale = 0.25
|
||||
# Don't set pitch scale too low as it sounds strange.
|
||||
# `0.5` is the square root of `0.25` and gives a good result here.
|
||||
AudioServer.playback_speed_scale = 0.5
|
||||
|
||||
if event.is_action_released(&"slow_motion"):
|
||||
if input_event.is_action_released(&"slow_motion"):
|
||||
Engine.time_scale = 1.0
|
||||
AudioServer.playback_speed_scale = 1.0
|
||||
|
||||
# Pan the camera with right mouse button.
|
||||
if event is InputEventMouseMotion:
|
||||
var mouse_motion := event as InputEventMouseMotion
|
||||
if input_event is InputEventMouseMotion:
|
||||
var mouse_motion := input_event as InputEventMouseMotion
|
||||
if mouse_motion.button_mask & MOUSE_BUTTON_RIGHT:
|
||||
camera_pivot.global_rotation.x = clampf(camera_pivot.global_rotation.x - event.screen_relative.y * MOUSE_SENSITIVITY, -TAU * 0.249, TAU * 0.021)
|
||||
camera_pivot.global_rotation.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
camera_pivot.global_rotation.x = clampf(camera_pivot.global_rotation.x - input_event.screen_relative.y * MOUSE_SENSITIVITY, -TAU * 0.249, TAU * 0.021)
|
||||
camera_pivot.global_rotation.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
|
||||
# Zoom with mouse wheel.
|
||||
# This also adjusts shadow maximum distance to always cover the scene regardless of zoom level.
|
||||
if event is InputEventMouseButton:
|
||||
var mouse_button := event as InputEventMouseButton
|
||||
if input_event is InputEventMouseButton:
|
||||
var mouse_button := input_event as InputEventMouseButton
|
||||
if mouse_button.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera.translate_object_local(Vector3.FORWARD * 0.5)
|
||||
directional_light.directional_shadow_max_distance = camera.position.length() + DIRECTIONAL_SHADOW_MAX_DISTANCE_MARGIN
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.001
|
||||
|
||||
# The camera field of view to smoothly interpolate to.
|
||||
@@ -19,30 +20,30 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_gui"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"toggle_gui"):
|
||||
$Panel.visible = not $Panel.visible
|
||||
$Help.visible = not $Help.visible
|
||||
|
||||
if event.is_action_pressed(&"toggle_spheres"):
|
||||
if input_event.is_action_pressed(&"toggle_spheres"):
|
||||
$Spheres.visible = not $Spheres.visible
|
||||
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED and event is InputEventMouseMotion:
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED and input_event is InputEventMouseMotion:
|
||||
# Mouselook.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
$YawCamera.rotation.x = clampf($YawCamera.rotation.x - relative_motion.y * MOUSE_SENSITIVITY, -TAU * 0.25, TAU * 0.25)
|
||||
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
|
||||
|
||||
# Mouse wheel currently doesn't work in input actions. Hardcode mouse wheel as a workaround.
|
||||
if event.is_action_pressed(&"increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
|
||||
if input_event.is_action_pressed(&"increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
|
||||
desired_fov = clampf(desired_fov + 5.0, 20.0, 120.0)
|
||||
if event.is_action_pressed(&"decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
|
||||
if input_event.is_action_pressed(&"decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
|
||||
desired_fov = clampf(desired_fov - 5.0, 20.0, 120.0)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED: float = 0.003
|
||||
const ZOOM_SPEED: float = 0.125
|
||||
const MAIN_BUTTONS: int = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -63,13 +64,13 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event.is_action_pressed(&"reset_physics_simulation"):
|
||||
if input_event.is_action_pressed(&"reset_physics_simulation"):
|
||||
# Remove all additional (player-spawned) items.
|
||||
for additional_item in additional_items:
|
||||
additional_item.queue_free()
|
||||
@@ -92,9 +93,9 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
nodes_to_reset[idx].set_point_pinned(point, true)
|
||||
|
||||
if (
|
||||
event.is_action_pressed(&"place_cloth") or
|
||||
event.is_action_pressed(&"place_light_box") or
|
||||
event.is_action_pressed(&"place_heavy_box")
|
||||
input_event.is_action_pressed(&"place_cloth") or
|
||||
input_event.is_action_pressed(&"place_light_box") or
|
||||
input_event.is_action_pressed(&"place_heavy_box")
|
||||
):
|
||||
# Place a new item and track it in an additional items array, so we can limit
|
||||
# the number of player-spawned items present in the scene at a given time.
|
||||
@@ -111,11 +112,11 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
additional_items.pop_front().queue_free()
|
||||
|
||||
var node: Node3D
|
||||
if event.is_action_pressed(&"place_cloth"):
|
||||
if input_event.is_action_pressed(&"place_cloth"):
|
||||
node = Cloth.instantiate()
|
||||
# Make user-placed cloth translucent to distinguish from the scene's own cloths.
|
||||
node.transparency = 0.35
|
||||
elif event.is_action_pressed(&"place_light_box"):
|
||||
elif input_event.is_action_pressed(&"place_light_box"):
|
||||
node = RigidBoxLight.instantiate()
|
||||
else:
|
||||
node = RigidBoxHeavy.instantiate()
|
||||
@@ -124,16 +125,16 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
add_child(node)
|
||||
additional_items.push_back(node)
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clampf(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Compensate motion speed to be resolution-independent (based on the window height).
|
||||
var relative_motion: Vector2 = event.relative * DisplayServer.window_get_size().y / base_height
|
||||
var relative_motion: Vector2 = input_event.relative * DisplayServer.window_get_size().y / base_height
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clampf(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -21,22 +22,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
|
||||
@@ -28,8 +28,8 @@ func _ready() -> void:
|
||||
add_child(compatibility_light)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"cycle_mood"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"cycle_mood"):
|
||||
mood = wrapi(mood + 1, 0, Mood.MAX) as Mood
|
||||
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ func _ready() -> void:
|
||||
update_camera()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"cycle_camera"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"cycle_camera"):
|
||||
camera_type = wrapi(camera_type + 1, 0, CameraType.MAX) as CameraType
|
||||
update_camera()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
@onready var option_button: OptionButton = $CanvasLayer/VBoxContainer/HBoxContainer/OptionButton
|
||||
@onready var texture_rect: TextureRect = $CanvasLayer/VBoxContainer/TextureRect
|
||||
@onready var camera: Camera3D = $Camera3D
|
||||
@@ -9,6 +10,7 @@ extends Node3D
|
||||
|
||||
var xr_interface: MobileVRInterface
|
||||
|
||||
|
||||
func _set_xr_mode() -> void:
|
||||
var vrs_mode := get_viewport().vrs_mode
|
||||
if vrs_mode == Viewport.VRS_XR:
|
||||
|
||||
@@ -32,42 +32,42 @@ func _process(delta: float) -> void:
|
||||
position += velocity
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
transform.basis = Basis.from_euler(rot)
|
||||
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
if event.is_action_pressed(&"toggle_temporal_reprojection"):
|
||||
if input_event.is_action_pressed(&"toggle_temporal_reprojection"):
|
||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled = not get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"increase_temporal_reprojection"):
|
||||
elif input_event.is_action_pressed(&"increase_temporal_reprojection"):
|
||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount + 0.01, 0.5, 0.99)
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"decrease_temporal_reprojection"):
|
||||
elif input_event.is_action_pressed(&"decrease_temporal_reprojection"):
|
||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount - 0.01, 0.5, 0.99)
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"increase_fog_density"):
|
||||
elif input_event.is_action_pressed(&"increase_fog_density"):
|
||||
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density + 0.01, 0.0, 1.0)
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"decrease_fog_density"):
|
||||
elif input_event.is_action_pressed(&"decrease_fog_density"):
|
||||
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density - 0.01, 0.0, 1.0)
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"increase_volumetric_fog_quality"):
|
||||
elif input_event.is_action_pressed(&"increase_volumetric_fog_quality"):
|
||||
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size + 16, 16, 384)
|
||||
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
|
||||
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
||||
update_label()
|
||||
elif event.is_action_pressed(&"decrease_volumetric_fog_quality"):
|
||||
elif input_event.is_action_pressed(&"decrease_volumetric_fog_quality"):
|
||||
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size - 16, 16, 384)
|
||||
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
|
||||
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
||||
|
||||
@@ -120,10 +120,10 @@ func _physics_process(delta: float) -> void:
|
||||
velocity.y = MOVEMENT_JUMP_VELOCITY
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseMotion:
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
_mouse_motion += event.screen_relative
|
||||
_mouse_motion += input_event.screen_relative
|
||||
|
||||
|
||||
func chunk_pos() -> Vector3i:
|
||||
|
||||
@@ -13,7 +13,7 @@ const DIRECTIONS: Array[Vector3i] = [Vector3i.LEFT, Vector3i.RIGHT, Vector3i.DOW
|
||||
|
||||
var data: Dictionary[Vector3i, int] = {}
|
||||
var chunk_position := Vector3i()
|
||||
var is_initial_mesh_generated := false
|
||||
var is_initial_mesh_generated: bool = false
|
||||
var mesh_task_id := 0
|
||||
|
||||
static var box_shape: BoxShape3D = null
|
||||
|
||||
@@ -15,8 +15,8 @@ var _delete_distance := 0
|
||||
var effective_render_distance := 0
|
||||
var _old_player_chunk := Vector3i()
|
||||
|
||||
var _generating := true
|
||||
var _deleting := false
|
||||
var _generating: bool = true
|
||||
var _deleting: bool = false
|
||||
|
||||
var _chunks: Dictionary[Vector3i, Chunk] = {}
|
||||
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.002
|
||||
const MOVE_SPEED = 0.65
|
||||
|
||||
var rot := Vector3()
|
||||
var velocity := Vector3()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
transform.basis = Basis.from_euler(rot)
|
||||
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||
# Use PCF13 shadow filtering to improve quality (Medium maps to PCF5 instead).
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
extends Control
|
||||
|
||||
|
||||
## Some margin to keep the marker away from the screen's corners.
|
||||
const MARGIN = 8
|
||||
|
||||
## The waypoint's text.
|
||||
@export var text := "Waypoint":
|
||||
@export var text: String = "Waypoint":
|
||||
set(value):
|
||||
text = value
|
||||
# The label's text can only be set once the node is ready.
|
||||
@@ -12,13 +13,14 @@ const MARGIN = 8
|
||||
label.text = value
|
||||
|
||||
## If `true`, the waypoint sticks to the viewport's edges when moving off-screen.
|
||||
@export var sticky := true
|
||||
@export var sticky: bool = true
|
||||
|
||||
@onready var camera := get_viewport().get_camera_3d()
|
||||
@onready var parent := get_parent()
|
||||
@onready var label: Label = $Label
|
||||
@onready var marker: TextureRect = $Marker
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
self.text = text
|
||||
assert(parent is Node3D, "The waypoint's parent node must inherit from Node3D.")
|
||||
|
||||
Reference in New Issue
Block a user