How do I fix glitching - Kinetmatic Movement 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mobileMojo

SO, I have a vehicle that uses custom movement for KinematicBody. The issue is, ONLY when I am moving or turning at angles that are not normal to X, Z, the game struggles to keep frames due to likely _physics_process(delta).

Here is the movement so far:

export var steering_limit = 15  # front wheel max turning angle (deg)
var acceleration = Vector3.ZERO  # current acceleration
var velocity = Vector3.ZERO  # current velocity
export var engine_power = 10
export var braking = -6.0

func get_input(delta):
camSwitch()
if is_on_floor():
	if Input.get_action_strength("turnLeft"):
		rotate_y(steering_limit)
	elif Input.get_action_strength("turnRight"):
		rotate_y(-steering_limit)
	acceleration = Vector3.ZERO
	if Input.is_action_pressed("accel"):
		acceleration = -transform.basis.z * engine_power
	if Input.is_action_pressed("reverse"):
		acceleration = -transform.basis.z * braking

Here is the moveandslide physics process:

func _physics_process(delta):
if active == false:
	if is_on_floor():
		velocity = Vector3.ZERO
	elif not is_on_floor():
		acceleration.y = gravity
		velocity += acceleration * delta
		velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)
elif active == true:
	hidden_plyr.global_transform.origin = get_parent().get_node("Terrain").transform.origin + Vector3(0,2000,0)
	if is_on_floor():
		get_input(delta)
		apply_friction(delta)
		calculate_steering(delta)
	acceleration.y = gravity
	velocity += acceleration * delta
	velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)

NOTE: I know I can use move and slide without snap but Id prefer it so I can calculate for normals on hills and such and interpolate that with snapping, unless I dont have to. IDK yet, still trying things out, all possibilities atm.

But any ideas? Thank you if you can help :slight_smile: Hope all is well!