gd: mantle end location system

This commit is contained in:
2025-05-23 11:19:27 +02:00
parent b340fe21c7
commit 29d196acdf
11 changed files with 73 additions and 31 deletions

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://boasm0g587eov"
path.s3tc="res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Dark/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.s3tc.ctex", "res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://3e1klega6uye"
path.s3tc="res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Green/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.s3tc.ctex", "res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://0t6ie0fkv2op"
path.s3tc="res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Light/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.s3tc.ctex", "res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://t10lfkxrg7ay"
path.s3tc="res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Orange/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.s3tc.ctex", "res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dgix86l87u86s"
path.s3tc="res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Red/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.s3tc.ctex", "res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://woq2hudxhckr"
path.s3tc="res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.s3tc.ctex"
path.etc2="res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/PerlinNoise/Gabor 1 - 512x512.png"
dest_files=["res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"]
dest_files=["res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.s3tc.ctex", "res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://lp2pt8mtj7ty"
path.s3tc="res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.s3tc.ctex"
path.etc2="res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Examples/MovementTestbed/Hills/kenney-green-checkerboar-cc0.png"
dest_files=["res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"]
dest_files=["res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.s3tc.ctex", "res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"]
[params]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://bei4nhkf8lwdo"]
[gd_scene load_steps=23 format=3 uid="uid://bei4nhkf8lwdo"]
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
[ext_resource type="Material" uid="uid://dtq8i1ka1f2pn" path="res://player_controller/Assets/Materials/Health/CameraVignette.tres" id="2_6hee7"]
@ -24,6 +24,8 @@ shader = ExtResource("4_jyscr")
shader_parameter/limit = 0.0
shader_parameter/blur = 0.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4coqe"]
[sub_resource type="Animation" id="Animation_vcu7l"]
length = 0.001
tracks/0/type = "bezier"
@ -185,10 +187,24 @@ target_position = Vector3(0, -0.75, 0)
[node name="MantleSystem" type="Node3D" parent="."]
script = ExtResource("14_4coqe")
MantleEndLocationDistanceFromWall = 0.2
MantleHeightCastStart = 3.0
[node name="MantleCast3D" type="ShapeCast3D" parent="."]
shape = SubResource("CapsuleShape3D_4coqe")
target_position = Vector3(0, 0, 0)
debug_shape_custom_color = Color(1, 0, 0, 1)
[node name="WallInFrontCast3D" type="ShapeCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_4coqe")
target_position = Vector3(0, 0, -2)
debug_shape_custom_color = Color(1, 0, 0, 1)
[node name="WallInFrontRayCast3D" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1.65, 0)
target_position = Vector3(0, -1.5, 0)
enabled = false
target_position = Vector3(0, -2, 0)
[node name="StairsSystem" type="Node3D" parent="."]
script = ExtResource("7_bmt5a")

View File

@ -4,29 +4,48 @@ namespace PolarBears.PlayerControllerAddon;
public partial class MantleSystem: Node3D
{
private RayCast3D _wallInFrontRaycast3D;
[Export(PropertyHint.Range, "0,2,0.1,or_greater")]
public float MantleEndLocationDistanceFromWall { get; set; } = 1f;
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float MantleHeightCastStart { get; set; } = 2f;
[Export(PropertyHint.Range, "0,10,0.01,suffix:m,or_greater")]
public float MaxStepHeight = 0.5f;
private Node3D _head;
private ShapeCast3D _wallInFrontCast3D;
private ShapeCast3D _mantleCast3D;
public void Init(RayCast3D wallInFrontRaycast3D, Node3D head)
public void Init(ShapeCast3D wallInFrontCast3D, Node3D head, ShapeCast3D mantleCast3D)
{
_wallInFrontRaycast3D = wallInFrontRaycast3D;
_wallInFrontCast3D = wallInFrontCast3D;
_head = head;
_mantleCast3D = mantleCast3D;
}
public void CheckWallInFront()
public Vector3 CheckWallInFront()
{
_wallInFrontRaycast3D.SetRotation(new Vector3(
_wallInFrontRaycast3D.Rotation.X,
_wallInFrontCast3D.SetRotation(new Vector3(
_wallInFrontCast3D.Rotation.X,
_head.Rotation.Y,
_wallInFrontRaycast3D.Rotation.Z));
_wallInFrontCast3D.Rotation.Z));
var collider = _wallInFrontRaycast3D.GetCollider();
if (collider == null)
if (!_wallInFrontCast3D.IsColliding())
{
return;
return Vector3.Zero;
}
GD.Print(_wallInFrontRaycast3D.GetCollisionPoint());
GD.Print(_wallInFrontRaycast3D.GetCollisionNormal());
Vector3 collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
Vector3 horizontalEndLocation = collisionPoint - _wallInFrontCast3D.GetCollisionNormal(0) * MantleEndLocationDistanceFromWall;
Vector3 shapeCastStartLocation = horizontalEndLocation + Vector3.Up * MantleHeightCastStart;
_mantleCast3D.SetGlobalPosition(shapeCastStartLocation);
Vector3 targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight;
_mantleCast3D.SetTargetPosition(targetLocation);
if (!_mantleCast3D.IsColliding())
{
return Vector3.Zero;
}
return _mantleCast3D.GetCollisionPoint(0);
}
}

View File

@ -59,7 +59,8 @@ public partial class PlayerController : CharacterBody3D
RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D");
RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D");
RayCast3D wallInFrontRaycast3D = GetNode<RayCast3D>("WallInFrontRayCast3D");
ShapeCast3D wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D");
ShapeCast3D mantleCast3D = GetNode<ShapeCast3D>("MantleCast3D");
Node3D cameraSmooth = GetNode<Node3D>("Head/CameraSmooth");
@ -93,7 +94,7 @@ public partial class PlayerController : CharacterBody3D
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
MantleSystem = GetNode<MantleSystem>("MantleSystem");
MantleSystem.Init(wallInFrontRaycast3D, Head);
MantleSystem.Init(wallInFrontCast3D, Head, mantleCast3D);
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");

View File

@ -23,7 +23,6 @@ public partial class StairsSystem: Node3D
_stairsBelowRayCast3D = stairsBelowRayCast3D;
_stairsAheadRayCast3D = stairsAheadRayCast3D;
_cameraSmooth = cameraSmooth;
}
public bool WasSnappedToStairsLastFrame() { return _snappedToStairsLastFrame; }