Add noclip mode (F3)
This commit is contained in:
parent
5c69f5c4df
commit
7b9a43394c
@ -121,6 +121,11 @@ toggle_pause_menu={
|
|||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
toggle_noclip={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
[ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://scenes/hazy_env_camera_attrs.tres" id="1_r2j1d"]
|
[ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://scenes/hazy_env_camera_attrs.tres" id="1_r2j1d"]
|
||||||
[ext_resource type="PackedScene" uid="uid://br315evr8x2gt" path="res://scenes/hazy_env.tscn" id="2_le85m"]
|
[ext_resource type="PackedScene" uid="uid://br315evr8x2gt" path="res://scenes/hazy_env.tscn" id="2_le85m"]
|
||||||
[ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://scenes/demo/demo.lmbake" id="2_thfwf"]
|
[ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://scenes/demo/demo.lmbake" id="2_thfwf"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/demo/demo_map.tscn" id="4_0ojvw"]
|
[ext_resource type="PackedScene" uid="uid://d4fn0ljcmjdnb" path="res://scenes/demo/demo_map.tscn" id="4_0ojvw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://scenes/player.tscn" id="10_3xiy2"]
|
[ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://scenes/player.tscn" id="10_3xiy2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d02cqylu3xwos" path="res://scenes/table.tscn" id="11_7trvw"]
|
[ext_resource type="PackedScene" uid="uid://d02cqylu3xwos" path="res://scenes/table.tscn" id="11_7trvw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c670g1qg5gaug" path="res://scenes/interface/pause_menu.tscn" id="11_lav3p"]
|
[ext_resource type="PackedScene" uid="uid://c670g1qg5gaug" path="res://scenes/interface/pause_menu.tscn" id="11_lav3p"]
|
||||||
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://textures/building_block.tres" id="12_i3ahj"]
|
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://materials/building_block.tres" id="12_i3ahj"]
|
||||||
|
|
||||||
[node name="Demo" type="Node3D"]
|
[node name="Demo" type="Node3D"]
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ namespace Gmtk24 {
|
|||||||
private float JumpBufferTime = 0;
|
private float JumpBufferTime = 0;
|
||||||
private float FootstepCooldown = 0;
|
private float FootstepCooldown = 0;
|
||||||
|
|
||||||
|
private bool NoclipEnabled = false;
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event) {
|
public override void _UnhandledInput(InputEvent @event) {
|
||||||
if (@event is InputEventMouseMotion mouseMotion && Input.MouseMode == Input.MouseModeEnum.Captured) {
|
if (@event is InputEventMouseMotion mouseMotion && Input.MouseMode == Input.MouseModeEnum.Captured) {
|
||||||
var cameraSensitivity = UserSettings.Singleton.GetCameraSpeedMultipliers();
|
var cameraSensitivity = UserSettings.Singleton.GetCameraSpeedMultipliers();
|
||||||
@ -42,6 +44,19 @@ namespace Gmtk24 {
|
|||||||
|
|
||||||
if (@event.IsActionPressed("jump")) {
|
if (@event.IsActionPressed("jump")) {
|
||||||
JumpBufferTime = JumpBufferLengthSeconds;
|
JumpBufferTime = JumpBufferLengthSeconds;
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("toggle_noclip")) {
|
||||||
|
NoclipEnabled = !NoclipEnabled;
|
||||||
|
if (NoclipEnabled) {
|
||||||
|
CollisionLayer = 0;
|
||||||
|
CollisionMask = 0;
|
||||||
|
} else {
|
||||||
|
CollisionLayer = 1;
|
||||||
|
CollisionMask = 1;
|
||||||
|
}
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +100,12 @@ namespace Gmtk24 {
|
|||||||
Input.GetActionStrength("move_backward") - Input.GetActionStrength("move_forward")
|
Input.GetActionStrength("move_backward") - Input.GetActionStrength("move_forward")
|
||||||
);
|
);
|
||||||
Vector3 move = Eye.Basis * moveInput;
|
Vector3 move = Eye.Basis * moveInput;
|
||||||
|
|
||||||
|
if (NoclipEnabled) {
|
||||||
|
GlobalPosition += move * MovementSpeed * 10 * (float)delta;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
move.Y = 0;
|
move.Y = 0;
|
||||||
move = move.Normalized() * Mathf.Min(1, moveInput.Length()) * MovementSpeed;
|
move = move.Normalized() * Mathf.Min(1, moveInput.Length()) * MovementSpeed;
|
||||||
if (Input.IsActionPressed("sprint")) {
|
if (Input.IsActionPressed("sprint")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user