How can you write a first person controller script in GDscript and apply it to a KinematicBody-node when using Godot Engine 3.x and what is the equivalent to the KinematicBody-node in Godot Engine 4.x and how does the first person controller script need to be changed to work in Godot Engine 4.x?
Here's an example of a first-person controller script in GDscript for Godot Engine 3.x, applied to a KinematicBody node:
extends KinematicBody

var speed = 5
var gravity = 9.8
var jump_speed = 8

func _physics_process(delta):
    var velocity = Vector3()

    if is_on_floor():
        velocity.y = -gravity
    if Input.is_action_pressed("ui_up"):
        velocity.z -= speed
    if Input.is_action_pressed("ui_down"):
        velocity.z += speed
    if Input.is_action_pressed("ui_left"):
        velocity.x -= speed
    if Input.is_action_pressed("ui_right"):
        velocity.x += speed
    if Input.is_action_just_pressed("jump") and is_on_floor():
        velocity.y = jump_speed

    move_and_slide(velocity)

In Godot Engine 4.x, the equivalent node to the KinematicBody is the RigidBody. The equivalent first-person controller script would look like this:

extends RigidBody

var speed = 5
var gravity = 9.8
var jump_speed = 8

func _physics_process(delta):
    var velocity = Vector3()

    if is_on_floor():
        velocity.y = -gravity
    if Input.is_action_pressed("ui_up"):
        velocity.z -= speed
    if Input.is_action_pressed("ui_down"):
        velocity.z += speed
    if Input.is_action_pressed("ui_left"):
        velocity.x -= speed
    if Input.is_action_pressed("ui_right"):
        velocity.x += speed
    if Input.is_action_just_pressed("jump") and is_on_floor():
        velocity.y = jump_speed

    move_and_slide(velocity)

Note that in this example, the use of move_and_slide() is replaced with apply_impulse() to apply the velocity changes to the rigid body.