fix: correctly detecting items horizontally in front of player
This commit is contained in:
@ -187,7 +187,8 @@ target_position = Vector3(0, -0.75, 0)
|
||||
script = ExtResource("14_4coqe")
|
||||
|
||||
[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.5)
|
||||
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)
|
||||
|
||||
[node name="StairsSystem" type="Node3D" parent="."]
|
||||
script = ExtResource("7_bmt5a")
|
||||
|
@ -5,19 +5,28 @@ namespace PolarBears.PlayerControllerAddon;
|
||||
public partial class MantleSystem: Node3D
|
||||
{
|
||||
private RayCast3D _wallInFrontRaycast3D;
|
||||
private Node3D _head;
|
||||
|
||||
public void Init(RayCast3D wallInFrontRaycast3D)
|
||||
public void Init(RayCast3D wallInFrontRaycast3D, Node3D head)
|
||||
{
|
||||
_wallInFrontRaycast3D = wallInFrontRaycast3D;
|
||||
_head = head;
|
||||
}
|
||||
|
||||
public void CheckWallInFront()
|
||||
{
|
||||
_wallInFrontRaycast3D.SetRotation(new Vector3(
|
||||
_wallInFrontRaycast3D.Rotation.X,
|
||||
_head.Rotation.Y,
|
||||
_wallInFrontRaycast3D.Rotation.Z));
|
||||
|
||||
var collider = _wallInFrontRaycast3D.GetCollider();
|
||||
if (collider != null)
|
||||
if (collider == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GD.Print(_wallInFrontRaycast3D.GetCollisionPoint());
|
||||
GD.Print(_wallInFrontRaycast3D.GetCollisionNormal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||
|
||||
MantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
MantleSystem.Init(wallInFrontRaycast3D);
|
||||
MantleSystem.Init(wallInFrontRaycast3D, Head);
|
||||
|
||||
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");
|
||||
|
||||
|
Reference in New Issue
Block a user