Passing objects through others with registration

Godot Version

4.3

Question

Hello everyone!)
I’m making a turn-based game - a mix of Phoenixpoint, Jagges Aliance2, XCom.
And I have a problem:

  • I want the bullets (RigidBody3D → CollisionShape3D) to pierce the object (staticBody → ColisionShape3D) while registering the interaction (KinematicCollision3D)

  • usually with move_and_collide, bullets bounce or stop

  • I arrived at the interaction to change the mask of the bullet (RigidBody3D ) and leave the vector - but there was a problem - how to return the mask back when the bullet left the staticBody

  • if you change the mask of staticBody, then the problem remains and there is a chance that other bullets in the queue will fly nearby

  • how to solve such a problem gracefully?


i create this and it works for me

    private Transform3D _transform3D;
   private _triggerBreakthrough = false;
    public override void _PhysicsProcess(double delta)
    {
        if (!_triggerBreakthrough)
        {
            var collision = MoveAndCollide(_pw * (float)delta);
            if (collision != null)
            {

                if (CheckCollision(collision, angle))
                    Destroy();
                _triggerBreakthrough = true;
                _transform3D = Transform;
            }
        }
        else
        {
            _transform3D.Origin += _pw * (float)delta;
            if (!TestMove(_transform3D, _pw * 0.01f))
            {
                _triggerBreakthrough = false;
                Transform = _transform3D;
            }
        }
    }