The Shapecast just snapping after jumping near staticbody

Godot Version

Godot 4.6.2

Question: ShapeCast3D snaps after jumping near a StaticBody3D

Hello everyone! I am running into an issue where my ShapeCast3D node gets permanently offset from my character model after I jump near a StaticBody3D.

Before jumping, the ShapeCast3D is perfectly aligned with my character. However, after a jump, it becomes misaligned. This bug allows the player to press the jump button again before their feet even touch the ground (StaticBody3D).

public partial class Player : RigidBody3D
{
private bool _isOnGround;
private bool _jumpPressed;
public override void _Ready()
	{
		_groundRay = GetNode<ShapeCast3D>("GroundRay");
	}

    public override void _UnhandledInput(InputEvent @event)
	{
		if (@event.IsActionPressed("jump"))
		{
			_jumpPressed = true;
		}
	}
   public override void _PhysicsProcess(double delta)
	{
        _groundRay.ForceShapecastUpdate();
        UpdateGroundState();
        if (_isOnGround && _jumpPressed)
		{
			_jumpPressed = false;
			ApplyCentralImpulse(Vector3.Up * (JumpVelocity * Mass));
		}
		else if (_isOnGround)
		{
			_jumpPressed = false;
		}
    }

    private void UpdateGroundState()
	{
		_isOnGround = _groundRay.IsColliding();
	}

}

with the images proof shown as below :

Post your scene tree structure.

where does your shapecast start? It can’t (or will have significant trouble) detecting shapes it’s inside of, so if your cast starts at around the model’s shoulders then it may be inside of the cube and fail to detect it.

You probably also do not need to force raycast updates, doubling-up on raycast work

This is the player’s scene tree structure. I’m using a ShapeCast as a ground ray so the player can jump when the character hits the floor. I suppose there’s also a built-in method called IsOnFloor(), but I think it can only be used when the player’s node inherits from CharacterBody

The ShapeCast starts at the feet of the character’s model. It acts as a ground ray so the player can jump when the character hits the floor. However, when it gets close to another StaticBody, it snaps, as shown in the screenshot I posted.