Can someone tell me please how do ia recode this in godot 4? @xyz
extends KinematicBody


export var speed = 4.0
onready var pivot = $Pivot
onready var mesh = $Pivot/MeshInstance
onready var tween = $Tween
func physics_process(delta):
var forward = Vector3.FORWARD
if Input.is_action_pressed("up"):
roll(forward)
if Input.is_action_pressed("down"):
roll(-forward)
if Input.is_action_pressed("right"):
roll(forward.cross(Vector3.UP))
if Input.is_action_pressed("left"):
roll(-forward.cross(Vector3.UP))
func roll(dir):
Do nothing if we're currently rolling.
if tween.is_active():
return
## Step 1: Offset the pivot
pivot.translate(dir)
mesh.translate(-dir)
## Step 2: Animate the rotation
var axis = dir.cross(Vector3.DOWN)
tween.interpolate_property(pivot, "transform:basis",
null, pivot.transform.basis.rotated(axis, PI/2),
1/speed, Tween.TRANS_QUAD, Tween.EASE_IN)
tween.start()
yield(tween, "tween_all_completed")
## Step3: Finalize movement and reverse the offset
transform.origin += dir * 2
pivot.transform = Transform.IDENTITY
mesh.transform.origin = Vector3(0, 1, 0)