-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added advanced player height control
Modified climbing to collapse player to a sphere to allow mounting climbed objects Added crouch movement provider
- Loading branch information
1 parent
8b360e3
commit 9160743
Showing
5 changed files
with
143 additions
and
5 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
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
81 changes: 81 additions & 0 deletions
81
addons/godot-xr-tools/functions/Function_Crouch_movement.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,81 @@ | ||
tool | ||
class_name Function_CrouchMovement | ||
extends MovementProvider | ||
|
||
## | ||
## Movement Provider for Crouching | ||
## | ||
## @desc: | ||
## This script works with the PlayerBody attached to the players ARVROrigin. | ||
## | ||
## When the player presses the selected button, the height is overridden | ||
## to the crouch height | ||
## | ||
|
||
|
||
# enum our buttons, should find a way to put this more central | ||
enum Buttons { | ||
VR_BUTTON_BY = 1, | ||
VR_GRIP = 2, | ||
VR_BUTTON_3 = 3, | ||
VR_BUTTON_4 = 4, | ||
VR_BUTTON_5 = 5, | ||
VR_BUTTON_6 = 6, | ||
VR_BUTTON_AX = 7, | ||
VR_BUTTON_8 = 8, | ||
VR_BUTTON_9 = 9, | ||
VR_BUTTON_10 = 10, | ||
VR_BUTTON_11 = 11, | ||
VR_BUTTON_12 = 12, | ||
VR_BUTTON_13 = 13, | ||
VR_PAD = 14, | ||
VR_TRIGGER = 15 | ||
} | ||
|
||
|
||
## Movement provider order | ||
export var order := 10 | ||
|
||
## Crouch height | ||
export var crouch_height := 1.0 | ||
|
||
## Crouch button | ||
export (Buttons) var crouch_button: int = Buttons.VR_PAD | ||
|
||
|
||
## Crouching flag | ||
var _crouching := false | ||
|
||
|
||
# Controller node | ||
onready var _controller : ARVRController = get_parent() | ||
|
||
|
||
# Perform jump movement | ||
func physics_movement(delta: float, player_body: PlayerBody, _disabled: bool): | ||
# Skip if the controller isn't active | ||
if !_controller.get_is_active(): | ||
return | ||
|
||
# Check for crouching change | ||
var crouching := _controller.is_button_pressed(crouch_button) != 0 | ||
if crouching == _crouching: | ||
return | ||
|
||
# Update crouching state | ||
_crouching = crouching | ||
if crouching: | ||
player_body.override_player_height(self, crouch_height) | ||
else: | ||
player_body.override_player_height(self) | ||
|
||
|
||
# This method verifies the MovementProvider has a valid configuration. | ||
func _get_configuration_warning(): | ||
# Check the controller node | ||
var test_controller = get_parent() | ||
if !test_controller or !test_controller is ARVRController: | ||
return "Unable to find ARVR Controller node" | ||
|
||
# Call base class | ||
return ._get_configuration_warning() |
6 changes: 6 additions & 0 deletions
6
addons/godot-xr-tools/functions/Function_Crouch_movement.tscn
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,6 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/godot-xr-tools/functions/Function_Crouch_movement.gd" type="Script" id=1] | ||
|
||
[node name="Function_Crouch_movement" type="Node" groups=["movement_providers"]] | ||
script = ExtResource( 1 ) |